home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / EDITORS / TEMPLED / TEMPED_SRC / Source (.txt) < prev   
RISC OS BBC BASIC V Source  |  1996-10-20  |  175KB  |  7,560 lines

  1.  Source code for !TemplEd
  2.  This application is FreeWare. (c) 1992-1995 Dick Alstein
  3. Appl$="TemplEd"
  4. Version$="1.32 (20-Oct-96)"
  5.  The following maximum values can be set to suit your needs
  6. 7MaxTemplates%=100  : 
  7.  max number of user templates
  8.     AMaxIcons%=200      : 
  9.  max number of icons in a user template
  10. GMaxIndirSize%=8000 : 
  11.  space for indirected data (only for loading)
  12.  *** main program and top-level procs ***
  13. Quit%=
  14. 2PollMask%=(1<<0)+(1<<4)+(1<<5)+(1<<11)+(1<<12)
  15. error(0)
  16.  Support%=3 
  17.  "WimpExt_PrePoll"
  18. /    
  19.  "Wimp_Poll",PollMask%,Blk% 
  20.  reason%
  21. <    
  22.  "WimpExt_Action",ThisTask%,Blk%,reason% 
  23.  reason%
  24. /    
  25.  "Wimp_Poll",PollMask%,Blk% 
  26.  reason%
  27.  reason% 
  28. ,      
  29.  "Wimp_GetPointerInfo",,PtrInfo%
  30. 1      
  31.  (PtrInfo%!8>0) 
  32.  Mbuttons_Released% 
  33. *        
  34.  signal press of mouse button
  35.          Mbuttons_Released%=
  36. N        
  37. click(PtrInfo%!0,PtrInfo%!4,PtrInfo%!8,PtrInfo%!12,PtrInfo%!16,0)
  38.       
  39.         
  40.  PtrInfo%!8=0 
  41. "9          
  42.  Mbuttons_Released%) 
  43.  (Drag_Type%=7) 
  44. #M            
  45.  detected end of workarea-resize - set bottomright corner of
  46. $9            
  47.  work area to currently visible position
  48. %#            WinBlk%!0=Drag_Win%
  49. &1            
  50.  "Wimp_GetWindowState",,WinBlk%
  51. ':            WinBlk%!52=WinBlk%!12-WinBlk%!4+WinBlk%!20
  52. (=            WinBlk%!48=-(WinBlk%!16-WinBlk%!8-WinBlk%!24)
  53. )4            Drag_Win%=
  54. redefinewindow(WinBlk%,
  55.           
  56. +"          Mbuttons_Released%=
  57.           Drag_Type%=-1
  58. -"          TimedDrag_Enabled%=
  59.         
  60. /G          
  61.  button still pressed - test if OK to start "timed drag"
  62. 0H          
  63. (PtrInfo%!0-ThisClickX%)+
  64. (PtrInfo%!4-ThisClickY%)>16 
  65. 1@            TimedDrag_Enabled%=
  66.  moved mouse since click
  67.           
  68. 3$          
  69.  TimedDrag_Enabled% 
  70. 4I            
  71. -ThisClickTime%)>DragInterval%) 
  72.  (PtrInfo%!16>=0) 
  73. 5&              
  74.  "Wimp_DragBox",-1
  75. 6D              
  76. starticondrag(PtrInfo%!8,PtrInfo%!12,PtrInfo%!16)
  77. 7&              TimedDrag_Enabled%=
  78.             
  79.           
  80.         
  81.       
  82.  1 : 
  83. redraw(Blk%!0)
  84.       
  85.  (Blk%!0=TemplW%)
  86. ?/        c%=(Blk%!12-Blk%!4) 
  87.  TemplW_IconX%
  88.         
  89.  c%<1 
  90.  c%=1
  91. A         
  92.  TemplW_Cols%<>c% 
  93.           TemplW_Cols%=c%
  94. C!          
  95. redefinebrowser(
  96.           Blk%!0=TemplW%
  97.         
  98.       
  99.       
  100.  Blk%!0=OptionsW% 
  101. H7        
  102. openpane(OptPaneW%,Blk%!28,Blk%!4,Blk%!16)
  103.         Blk%!28=OptPaneW%
  104.       
  105. K$      
  106.  "Wimp_OpenWindow",,Blk%
  107.       
  108.  Blk%!0=OptionsW% 
  109. M7        
  110. openpane(OptPaneW%,Blk%!28,Blk%!4,Blk%!16)
  111.       
  112. P$      no%=
  113. whichtemplate(Blk%!0)
  114.       
  115.  no%>=0 
  116.         
  117. closetemplate(no%)
  118.       
  119.         
  120.  -1) 
  121. U"          
  122. closewindow(Blk%!0)
  123.         
  124. W.        
  125.  "Wimp_GetPointerInfo",,PtrInfo%
  126. XD        
  127.  (Blk%!0=TemplW%)
  128. (PtrInfo%!8=1)
  129. MainFname$,".")>0) 
  130. YG          
  131.  "Wimp_StartTask","Filer_OpenDir "+
  132. dirname(MainFname$)
  133.         
  134.       
  135. \<    
  136.  6 : 
  137. click(Blk%!0,Blk%!4,Blk%!8,Blk%!12,Blk%!16,
  138. ]7    
  139.  7 : 
  140. finishdrag(Blk%!0,Blk%!4,Blk%!8,Blk%!12)
  141. ^)    
  142.  8 : 
  143. key(Blk%!0,Blk%!4,Blk%!24)
  144.  9 : 
  145. menuselect(Blk%)
  146. `     
  147.  17,18 : 
  148. receive(Blk%)
  149.  IcInfo_Active% 
  150. icinf_update
  151.  Quit%
  152. font_loseall
  153. support(0)
  154. msg_exit
  155.  "Wimp_CloseDown"
  156.  p%,fn$,i%,mask%,flg%
  157.  ErrBlk% &100
  158.  "Wimp_Initialise",200,&4B534154,Appl$ 
  159.  OSversion%,ThisTask%
  160. error(1)
  161.  ScrapBlk% &100      : 
  162.  block to hold various temporary data
  163. r'ApplDir$=
  164. readvarval("TemplEd$Dir")
  165. heap_init           : 
  166.  initialize heap
  167. msg_init            : 
  168.  load Messages file
  169.  lower bounds for Max* variables
  170.  MaxTemplates%<4 
  171.  MaxTemplates%=4
  172.  MaxIcons%<64 
  173.  MaxIcons%=64
  174.  MaxIndirSize%<&1000 
  175.  MaxIndirSize%=&1000
  176.  declaration of data blocks and arrays (variable size)
  177. SelBlkSize%=4*MaxIcons%
  178. {KSelBlk%=
  179. heap_get(SelBlkSize%)       : 
  180.  to hold list of selected icons
  181. |#SelBlk2%=
  182. heap_get(SelBlkSize%)
  183. }MTemplNames%=
  184. heap_get(MaxTemplates%*28) : 
  185.  to store template + icon name
  186. ~MTemplHandle%=
  187. heap_get(4*MaxTemplates%) : 
  188.  handles of the user templates
  189. PPaneFlag%=
  190. heap_get(MaxTemplates%)   : 
  191.  array for 'Pane' flags of templates
  192. EMaxTemplateSize%=92+32*MaxIcons%      : 
  193.  max size for a template
  194. MMaxTemplateSize%+=MaxIndirSize%       : 
  195.  extra space for indirected data
  196. 'WinBlk%=
  197. heap_get(MaxTemplateSize%)
  198. (FileIndexSize%=16+MaxTemplates%*24+4
  199. NFileIndex%=
  200. heap_get(FileIndexSize%) : 
  201.  contains index of a template file
  202.  declaration of data blocks and arrays (fixed size)
  203.  IconBlk% 40
  204.  Blk% &100           : 
  205.  for data returned by Wimp_Poll
  206.  PtrInfo% 20         : 
  207.  to store pointer info
  208.  NumValidStr% 8      : 
  209.  validation string for entering a number
  210. $NumValidStr%="A0-9"
  211.  FpNumValidStr% 8    : 
  212.  for entering a floating point number
  213. $FpNumValidStr%="A0-9."
  214. INrTemplates%=0                   : 
  215.  current number of user templates
  216. KTemplatesOpen%=0                 : 
  217.  number of templates currently open
  218. NSysIndirSize%=&1800         : 
  219.  size of indirected data for system windows
  220.  IndirBlk% SysIndirSize%
  221. @IndirEnd%=IndirBlk%         : 
  222.  pointer to first unused byte
  223. HIndirFree%=SysIndirSize%    : 
  224.  remaining free space after IndirEnd%
  225.  IconText%(36)           : 
  226.  pointers to indirected text icons
  227.  IconTextWhdl%(36)       : 
  228.  corresponding window handles
  229.  IconTextIhdl%(36)       : 
  230.  corresponding icon handles
  231.  CselText%(12)           : 
  232.  pointers to text in colour-select boxes
  233.  CselTextWhdl%(12)       : 
  234.  corresponding window handles
  235.  CselTextIhdl%(12)       : 
  236.  corresponding icon handles
  237.  IcButton% 20*16         : 
  238.  names of button types for icons
  239.  WinButton% 20*16        : 
  240.  names of button types for windows
  241.  i%=0 
  242. 3  $(IcButton%+20*i%)=
  243. msg_lookup0("ICBT"+
  244. (i%))
  245. 4  $(WinButton%+20*i%)=
  246. msg_lookup0("WNBT"+
  247. (i%))
  248.  WinEd_Col%(6)      : 
  249.  colours in the colour-select boxes
  250.  InverseColour%(15) : 
  251.  to display text in colour boxes / colour menu
  252.  i%=0 
  253.  0,1,2,3,9,12,14
  254.       InverseColour%(i%)=7
  255.         
  256.       InverseColour%(i%)=0
  257.  DragBlk% 40     : 
  258.  data block for starting drags
  259.  FontUsage%(256) : 
  260.  counts number of icons that use a font
  261.  Fra% 256        : 
  262.  font reference array for loading+saving templates
  263.  FontData% 64    : 
  264.  buffer for reading font data
  265.  Mouse_Ptt% 16        : 
  266.  pixel translation table for pointer changes
  267.  initialise global variables
  268. /IcEd_Win%=-1000          : 
  269.  invalid values
  270. IcEd_Icon%=-1000
  271. WinEd_Win%=-1
  272. 5Mbuttons_Released%=
  273.  to debounce mouse clicks
  274. ?ThisClickTime%=
  275.       : 
  276.  to store data of last mouse click
  277. ThisClickX%=-1000
  278. ThisClickY%=-1000
  279. ThisClickButton%=0
  280. ITimedDrag_Enabled%=
  281.  can I start "timed drag" from current click?
  282. LDragInterval%=50         : 
  283.  interval after which "timed drag" can start
  284. JDclickInterval%=50       : 
  285.  max time between clicks of a double-click
  286. HNextIconNr%=0            : 
  287.  for semi-automatic renumbering of icons
  288. :LastMenu%=-1             : 
  289.  handle of last menu shown
  290. FLastMenu_Win%=-31        : 
  291.  window above which last menu was made
  292. 4LastMenu_Icon%=-1        : 
  293.  icon handle of same
  294. ;MainFname$="Templates"   : 
  295.  save all templates as ....
  296. @SelFname$="Selection"    : 
  297.  save template selection as ....
  298. @ExportTname$="TemplText" : 
  299.  save exported templates as ....
  300. AExportIname$="IconNames" : 
  301.  save exported icon names as ....
  302. HSavingSelection%=
  303.    : 
  304.  was last save dialogue to save a selection?
  305. FExporting%=
  306.          : 
  307.  was last save dialogue to export as text?
  308. BQuitAfterSave%=
  309.      : 
  310.  quit program after current save proc?
  311. GNewFname$=""             : 
  312.  name of new template file to be loaded
  313. BChangesMade%=
  314.        : 
  315.  have current templates been modified?
  316. KUserSprites%=1  : 
  317.  sprites in user templates from Wimp area (at first)
  318. BSpriteFname$="" : 
  319.  name of sprite file if not using Wimp area
  320. CDrag_Type%=-1   : 
  321.  type of current drag operation (-1 => none)
  322. LSupport%=0      : 
  323.  is in setup, but must exist before loading templates
  324.  create icon on icon bar
  325. IconBlk%!0=-1
  326. IconBlk%!4=0 : IconBlk%!8=0
  327. #IconBlk%!12=68 : IconBlk%!16=68
  328. IconBlk%!20=&7000301A
  329. $(IconBlk%+24)="!templed"
  330.  "Wimp_CreateIcon",,IconBlk% 
  331.  BarIcon%
  332.  load system sprites
  333. 4SysSprites%=
  334. loadspritefile(ApplDir$+".Sprites")
  335.  initialise font reference arrays
  336.  i%=0 
  337.   Fra%?i%=0
  338.  load system templates and set pointers to indirected data
  339.  "Wimp_OpenTemplate",,ApplDir$+".Templates"
  340. ?InfoW%=
  341. loadtemplate("Info",WinBlk%,IndirEnd%,IndirFree%,1)
  342. $$(WinBlk%!(92+3*32+20))=Version$
  343. OTemplW%=
  344. loadtemplate("Templates",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  345. DTemplTbar%=WinBlk%!76           : 
  346.  pointer to text in title bar
  347. $(TemplTbar%)=MainFname$
  348. i%=WinBlk%+92
  349. ITemplW_IconX%=i%!8-i%!0 + 8     : 
  350.  size of an icon in browser window
  351.  TemplW_IconY%=i%!12-i%!4 + 8
  352. 2TemplW_IconFlags%=i%!16         : 
  353.  icon flags
  354. DTemplW_Cols%=(WinBlk%!12-WinBlk%!4) 
  355.  TemplW_IconX% : 
  356.  #columns
  357.  TemplW_Cols%<1 
  358.  TemplW_Cols%=1
  359. ScrapBlk%!0=TemplW%
  360. ScrapBlk%!4=0
  361.  "Wimp_DeleteIcon",,ScrapBlk% : 
  362.  icon is only used to set size
  363. MIcEdW%=
  364. loadtemplate("IconEdit",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  365. IcEdTbar%=WinBlk%!76
  366. linkicontext(0,WinBlk%,23)  : 
  367.  text in a text icon
  368. linkicontext(1,WinBlk%,24)  : 
  369.  name of a sprite
  370. linkicontext(2,WinBlk%,25)  : 
  371.  validation string
  372. linkicontext(3,WinBlk%,26)  : 
  373.  max size
  374. linkicontext(4,WinBlk%,28)  : 
  375.  icon button type
  376. linkicontext(5,WinBlk%,31)  : 
  377. linkicontext(19,WinBlk%,45) : 
  378.  font name
  379. linkicontext(20,WinBlk%,48) : 
  380.  font x size
  381. linkicontext(21,WinBlk%,51) : 
  382.  font y size
  383. linkcseltext(0,WinBlk%,34)  : 
  384.  foreground colour
  385. linkcseltext(1,WinBlk%,37)  : 
  386.  background colour
  387. PWinEdW%=
  388. loadtemplate("WindowEdit",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  389. WinEdTbar%=WinBlk%!76
  390. linkicontext(6,WinBlk%,23)  : 
  391.  window button type
  392. linkcseltext(2,WinBlk%,27)  : 
  393.  title foreground colour
  394. linkcseltext(3,WinBlk%,31)  : 
  395.  title background colour
  396. linkcseltext(4,WinBlk%,35)  : 
  397.  work area foreground colour
  398. linkcseltext(5,WinBlk%,39)  : 
  399.  work area background colour
  400. linkcseltext(6,WinBlk%,43)  : 
  401.  scrollbar inner colour
  402. linkcseltext(7,WinBlk%,47)  : 
  403.  scrollbar outer colour
  404. linkcseltext(8,WinBlk%,51)  : 
  405.  input focus colour
  406. DDefW%=
  407. loadtemplate("DefaultWin",WinBlk%,IndirEnd%,IndirFree%,1)
  408. BSaveW%=
  409. loadtemplate("SaveBox",WinBlk%,IndirEnd%,IndirFree%,1)
  410. GFileName%=WinBlk%!(92+1*32+20)  : 
  411.  pointer to file name in savebox
  412. >SaveFileIcon%=WinBlk%!(92+2*32+20) : 
  413.  draggable file-icon
  414. EIcInfoW%=
  415. loadtemplate("IconInfo",WinBlk%,IndirEnd%,IndirFree%,1)
  416. &IcInfo_Width%=WinBlk%!12-WinBlk%!4
  417. linkicontext(7,WinBlk%,6)   : 
  418.  template name
  419. linkicontext(8,WinBlk%,7)   : 
  420.  icon number
  421. linkicontext(9,WinBlk%,9)   : 
  422.  minimum x coordinate
  423. linkicontext(26,WinBlk%,10) : 
  424.  maximum x coordinate
  425. linkicontext(10,WinBlk%,11) : 
  426.  minimum y coordinate
  427. linkicontext(27,WinBlk%,8)  : 
  428.  maximum y coordinate
  429. linkicontext(11,WinBlk%,12) : 
  430.  icon size
  431. linkicontext(24,WinBlk%,13) : 
  432.  pointer position
  433. CExportW%=
  434. loadtemplate("Export",WinBlk%,IndirEnd%,IndirFree%,1)
  435. EExportName%=WinBlk%!(92+1*32+20)  : 
  436.  pointer to export-file name
  437. @ExportFileIcon%=WinBlk%!(92+2*32+20) : 
  438.  draggable file-icon
  439. MWorkW%=
  440. loadtemplate("WorkArea",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  441. linkicontext(12,WinBlk%,10) : 
  442.  top left X coord
  443. linkicontext(13,WinBlk%,13) : 
  444.  top left Y coord
  445. linkicontext(14,WinBlk%,16) : 
  446.  work area X size
  447. linkicontext(15,WinBlk%,19) : 
  448.  work area Y size
  449. linkicontext(16,WinBlk%,22) : 
  450.  min X size
  451. linkicontext(17,WinBlk%,25) : 
  452.  min Y size
  453. KAlignW%=
  454. loadtemplate("Align",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  455. selecticon(AlignW%,2,1)     : 
  456.  set align-left on
  457. selecticon(AlignW%,8,1)     : 
  458.  move icons
  459. OOptionsW%=
  460. loadtemplate("Options",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  461. OOptPaneW%=
  462. loadtemplate("OptPane",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  463. linkicontext(28,WinBlk%,19) : 
  464.  iconsize grid X size
  465. linkicontext(29,WinBlk%,23) : 
  466.  iconsize grid Y size
  467. linkicontext(30,WinBlk%,28) : 
  468.  iconpos grid X size
  469. linkicontext(31,WinBlk%,32) : 
  470.  iconpos grid Y size
  471.  NSpaceW%=
  472. loadtemplate("Spaceout",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  473. selecticon(SpaceW%,3,1)    : 
  474.  set space-vertically on
  475. selecticon(SpaceW%,4,1)    : 
  476.  set to fixed spacing
  477. linkicontext(18,WinBlk%,6) : 
  478.  space between icons
  479. SpaceOut_Space%=4
  480. seticontext(18,
  481. (SpaceOut_Space%))
  482. space_shadeicons
  483. 'KFrameW%=
  484. loadtemplate("Frame",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  485. linkicontext(32,WinBlk%,7)  : 
  486.  frame icon #
  487. linkicontext(33,WinBlk%,11) : 
  488.  space around icons
  489. linkicontext(34,WinBlk%,17) : 
  490.  label icon #
  491. linkicontext(35,WinBlk%,22) : 
  492.  left space for label
  493. selecticon(FrameW%,6,1)     : 
  494.  use icon for frame
  495. selecticon(FrameW%,15,1)    : 
  496.  no label
  497. selecticon(FrameW%,21,1)    : 
  498.  left-spaced label
  499. Frame_IconNo%=0
  500. Frame_Space%=24
  501. Frame_LabelNo%=0
  502. Frame_LeftSpace%=32
  503. seticontext(33,
  504. (Frame_Space%))
  505. seticontext(35,
  506. (Frame_LeftSpace%))
  507. 5JStatW%=
  508. loadtemplate("Stats",WinBlk%,IndirEnd%,IndirFree%,SysSprites%)
  509. 64Stat_Colours%=(WinBlk%!(92+5*32+16)) 
  510.  &FF000000
  511. 7EPaletteW%=
  512. loadtemplate("Palette",WinBlk%,IndirEnd%,IndirFree%,1)
  513. 8CDialW%=
  514. loadtemplate("Dialogue",WinBlk%,IndirEnd%,IndirFree%,1)
  515. Dial_Msg%=WinBlk%!(92+20)
  516. :IDial_Button1%=WinBlk%!(92+1*32+20) : 
  517.  pointer to text in left button
  518. ;KDial_Button2%=WinBlk%!(92+2*32+20) : 
  519.  pointer to text in middle button
  520. <JDial_Button3%=WinBlk%!(92+3*32+20) : 
  521.  pointer to text in right button
  522.  store colours and border flag of buttons
  523. >!mask%=(1<<2)+(1<<5)+(&FF<<24)
  524. ?3Dial_ButtonCol1%=(WinBlk%!(92+1*32+16)) 
  525.  mask%
  526. @3Dial_ButtonCol2%=(WinBlk%!(92+2*32+16)) 
  527.  mask%
  528. A3Dial_ButtonCol3%=(WinBlk%!(92+3*32+16)) 
  529.  mask%
  530.  "Wimp_CloseTemplate"
  531.  initialise font usage
  532.  i%=0 
  533.  Fra%?i%>0 
  534. F=    FontUsage%(i%)=1 : 
  535.  font is used by system templates
  536.     FontUsage%(i%)=0
  537. setup_load
  538. readscreenvars
  539. selecticon(OptPaneW%,13,IcInfo_Active%)
  540. selecticon(OptPaneW%,11,DuplNames%)
  541. selecticon(OptPaneW%,12,Hatch%)
  542. selecticon(OptPaneW%,16,Grid_SizeLock%)
  543. seticontext(28,
  544. (Grid_SizeX%))
  545. seticontext(29,
  546. (Grid_SizeY%))
  547. selecticon(OptPaneW%,25,Grid_PosLock%)
  548. seticontext(30,
  549. (Grid_PosX%))
  550. seticontext(31,
  551. (Grid_PosY%))
  552. selecticon(OptPaneW%,14,Save_Unselected%)
  553. selecticon(OptPaneW%,15,DeleteOutside%)
  554. selecticon(OptPaneW%,8,TrapDclick%)
  555. selecticon(OptPaneW%,35,IgnoreDeskFont%)
  556. support(Setup_Support%)
  557. selecticon(StatW%,1,Stats_Decimal%)
  558. selecticon(StatW%,2,
  559.  Stats_Decimal%)
  560. preparemenus
  561.  "OS_ReadModeVariable",27,0 
  562.  ;flg% : 
  563.  test if hires modes available
  564.  (flg% 
  565.  2)=0 
  566.   SprSuffix$="22"
  567.   SprSuffix$=""
  568.  calculate height of title bar
  569. WinBlk%!0=DefW%
  570.  "Wimp_GetWindowState",,WinBlk%
  571. WinBlk%!28=-2
  572.  "Wimp_OpenWindow",,WinBlk%
  573. i%=WinBlk%!12
  574.  "Wimp_GetWindowOutline",,WinBlk%
  575. TBarHeight%=WinBlk%!12-i%
  576.  "Wimp_CloseWindow",,WinBlk%
  577.  get filename that was given as argument with command
  578.  "OS_GetEnv" 
  579. fn$,"-quit")
  580.  p%>0 
  581. 34,p%+
  582. ("-quit"))
  583.  p%>0 
  584. 34,p%+1)
  585.  p%>0 
  586.     fn$=
  587. fn$,p%+1)
  588.     p%=
  589. fn$," ")
  590.  p%=0
  591. (fn$)>0 
  592. xA    
  593. templ_loadfile(fn$,1) : 
  594.  found filename - load the file
  595. setmainfname(fn$)
  596. setextent
  597. key(window%,icon%,key%)
  598.  i%,waslast%,dx%,dy%,no%,help$,xmin%,ymin%,xmax%,ymax%,xstep%,ystep%
  599.  (key%=27) 
  600.  (Drag_Type%<>-1) 
  601. abortdrag
  602.  window% 
  603.  IcEdW%
  604.       
  605.  key% 
  606. 0        
  607.  &18E,&18A,13 : 
  608.  down, tab, return
  609.           
  610.  icon%>0 
  611.             i%=icon%
  612.             waslast%=
  613.             
  614.               
  615.  i%=26 
  616.                 i%=23
  617. 5                waslast%=
  618.  caret went "round"
  619.               
  620.                 i%+=1
  621.               
  622. 9            
  623. iconshaded(IcEdW%,i%)) 
  624.  (i%=icon%)
  625. (            
  626.  waslast% 
  627.  (key%=13) 
  628. )              
  629. selecticon(IcEdW%,9,1)
  630. #              
  631. iced_readwin(-1)
  632. )              
  633. selecticon(IcEdW%,9,0)
  634.               i%=icon%
  635.             
  636. $            
  637. setcaret(IcEdW%,i%)
  638.           
  639. )        
  640.  &18F,&19A : 
  641.  up, shift+tab
  642.           
  643.  icon%>0 
  644.             i%=icon%
  645.             
  646.               
  647.  i%=23 
  648.                 i%=26
  649.               
  650.                 i%-=1
  651.               
  652. 9            
  653. iconshaded(IcEdW%,i%)) 
  654.  (i%=icon%)
  655. $            
  656. setcaret(IcEdW%,i%)
  657.           
  658.         
  659.  &181 : 
  660. 0          
  661.  "Wimp_GetPointerInfo",,PtrInfo%
  662. $          
  663.  PtrInfo%!12=IcEdW% 
  664.             help$=""
  665.              
  666.  PtrInfo%!16 
  667. 6              
  668.  14            : help$="Indirected"
  669. 6              
  670.  3,25          : help$="Validation"
  671. 3              
  672.  4,26          : help$="Maxsize"
  673. 2              
  674.  15            : help$="Border"
  675. 2              
  676.  16            : help$="Filled"
  677. 4              
  678.  17            : help$="Hcentred"
  679. 4              
  680.  18            : help$="Vcentred"
  681. 6              
  682.  19            : help$="Rjustified"
  683. 5              
  684.  20            : help$="Needshelp"
  685. 7              
  686.  21            : help$="Allowadjust"
  687. 4              
  688.  22            : help$="Halfsize"
  689. 6              
  690.  5,27,28,29    : help$="Buttontype"
  691. /              
  692.  6,30,31,32    : help$="ESG"
  693. 2              
  694.  39            : help$="Shaded"
  695. 1              
  696.  7,33,34,35    : help$="Fgcol"
  697. 1              
  698.  8,36,37,38    : help$="Bgcol"
  699. 0              
  700.  41            : help$="Font"
  701. 1              
  702.  1             : help$="Flags"
  703.             
  704.             
  705.  help$<>"" 
  706. 5              
  707. askhelp("TemplEd.IconInfo_"+help$)
  708.             
  709.           
  710.         
  711.  &182 : 
  712. %          
  713. selecticon(IcEdW%,9,1)
  714.           
  715. iced_readwin(-1)
  716. %          
  717. selecticon(IcEdW%,9,0)
  718.         
  719.  &183 : 
  720. &          
  721. selecticon(IcEdW%,10,1)
  722.           
  723. iced_readwin(-1)
  724. &          
  725. selecticon(IcEdW%,10,0)
  726. "          
  727. closewindow(IcEdW%)
  728. %          
  729. setcaret(IcEd_Win%,-1)
  730. !        
  731.  &184,27 : 
  732.  F4, Esc
  733. &          
  734. selecticon(IcEdW%,11,1)
  735. "          
  736. closewindow(IcEdW%)
  737. &          
  738. selecticon(IcEdW%,11,0)
  739. %          
  740. setcaret(IcEd_Win%,-1)
  741.         
  742. '          
  743.  "Wimp_ProcessKey",key%
  744.       
  745.  WinEdW%
  746.       
  747.  key% 
  748.         
  749.  &181     
  750. 0          
  751.  "Wimp_GetPointerInfo",,PtrInfo%
  752. %          
  753.  PtrInfo%!12=WinEdW% 
  754.             help$=""
  755.              
  756.  PtrInfo%!16 
  757. 4              
  758.  4             : help$="Moveable"
  759. 7              
  760.  5             : help$="Auto-redraw"
  761. 3              
  762.  6             : help$="Hotkeys"
  763. 0              
  764.  7             : help$="Pane"
  765. 4              
  766.  8             : help$="Nobounds"
  767. 0              
  768.  9             : help$="GCOL"
  769. 6              
  770.  10            : help$="Backwindow"
  771. 6              
  772.  1,21,22,23,24 : help$="Buttontype"
  773. 5              
  774.  20            : help$="Newformat"
  775. 4              
  776.  57            : help$="OnScreen"
  777. 2              
  778.  11,58,59,60   : help$="Scroll"
  779. 4              
  780.  12,61,62,63   : help$="NoExtent"
  781.             
  782.             
  783.  help$<>"" 
  784. 4              
  785. askhelp("TemplEd.WinInfo_"+help$)
  786.             
  787.           
  788.         
  789.  &182,13
  790. '          
  791. selecticon(WinEdW%,53,1)
  792.           
  793. wined_readwin
  794. '          
  795. selecticon(WinEdW%,53,0)
  796.         
  797.  &183
  798. '          
  799. selecticon(WinEdW%,54,1)
  800.           
  801. wined_readwin
  802. '          
  803. selecticon(WinEdW%,54,0)
  804. #          
  805. closewindow(WinEdW%)
  806. &          
  807. setcaret(WinEd_Win%,-1)
  808.         
  809.  &184,27
  810. '          
  811. selecticon(WinEdW%,55,1)
  812. #          
  813. closewindow(WinEdW%)
  814. '          
  815. selecticon(WinEdW%,55,0)
  816. &          
  817. setcaret(WinEd_Win%,-1)
  818.         
  819. '          
  820.  "Wimp_ProcessKey",key%
  821.       
  822.  SaveW%
  823.       
  824.  key% 
  825.         
  826. %          
  827. selecticon(SaveW%,0,1)
  828.           
  829.  Exporting% 
  830. .            
  831. exporttemplates($(FileName%))
  832.           
  833. $            
  834.  SavingSelection% 
  835. (              SelFname$=$(FileName%)
  836.     +              
  837. savetemplates(SelFname$)
  838.             
  839. -              
  840. setmainfname($(FileName%))
  841. ,              
  842. savetemplates(MainFname$)
  843.             
  844.           
  845. %          
  846. selecticon(SaveW%,0,0)
  847. &          
  848.  "Wimp_CreateMenu",,-1
  849.         
  850. '          
  851.  "Wimp_ProcessKey",key%
  852.       
  853.  ExportW%
  854.       
  855.  key% 
  856.         
  857. '          
  858. selecticon(ExportW%,0,1)
  859. /          
  860. export_savenames($(ExportName%))
  861. '          
  862. selecticon(ExportW%,0,0)
  863. &          
  864.  "Wimp_CreateMenu",,-1
  865.         
  866. '          
  867.  "Wimp_ProcessKey",key%
  868.       
  869.  WorkW%
  870.       
  871.  key% 
  872.         
  873.  &18E,&18A,13
  874.           
  875.  icon%=25 
  876.             
  877.  key%=13 
  878. #*              
  879. selecticon(WorkW%,30,1)
  880.               
  881. setworkarea
  882. %*              
  883. selecticon(WorkW%,30,0)
  884. &*              
  885.  "Wimp_CreateMenu",,-1
  886.             
  887. (&              
  888. setcaret(WorkW%,10)
  889.             
  890.           
  891. +)            
  892. setcaret(WorkW%,icon%+3)
  893.           
  894.         
  895.  &18F,&19A
  896.           
  897.  icon%=10 
  898. /$            
  899. setcaret(WorkW%,25)
  900.           
  901. 1)            
  902. setcaret(WorkW%,icon%-3)
  903.           
  904.         
  905. 4&          
  906.  "Wimp_CreateMenu",,-1
  907.         
  908. 6'          
  909.  "Wimp_ProcessKey",key%
  910.       
  911.  SpaceW%
  912.       
  913.  key%=13 
  914. :$        
  915. selecticon(SpaceW%,9,1)
  916. ;&        
  917. spaceicons(LastMenu_Win%)
  918. <$        
  919. selecticon(SpaceW%,9,0)
  920. =$        
  921.  "Wimp_CreateMenu",,-1
  922.       
  923. ?%        
  924.  "Wimp_ProcessKey",key%
  925.       
  926.  FrameW%
  927.       
  928.  key%=13 
  929. C$        
  930. selecticon(FrameW%,3,1)
  931. D$        
  932.  "Wimp_CreateMenu",,-1
  933. E&        
  934. frameicons(LastMenu_Win%)
  935. F$        
  936. selecticon(FrameW%,3,0)
  937.       
  938. H%        
  939.  "Wimp_ProcessKey",key%
  940.       
  941. J        
  942.       
  943.  Drag_Type% 
  944.         
  945.  0,1,5,6,7
  946.           dx%=0
  947.           dy%=0
  948.           
  949.  key% 
  950. P(            
  951.  &18C : dx%=-PixToOS_X%
  952. Q'            
  953.  &18D : dx%=PixToOS_X%
  954. R(            
  955.  &18E : dy%=-PixToOS_Y%
  956. S'            
  957.  &18F : dy%=PixToOS_Y%
  958. T*            
  959.  &19C : dx%=-4*PixToOS_X%
  960. U)            
  961.  &19D : dx%=4*PixToOS_X%
  962. V*            
  963.  &19E : dy%=-4*PixToOS_Y%
  964. W)            
  965.  &19F : dy%=4*PixToOS_Y%
  966. X-            
  967.  "Wimp_ProcessKey",key%
  968.           
  969. Z0          
  970.  "Wimp_GetPointerInfo",,PtrInfo%
  971. [4          
  972.  (PtrInfo%!0)+dx%,(PtrInfo%!4)+dy%
  973.         
  974. ])          no%=
  975. whichtemplate(window%)
  976.           
  977.  no%>=0 
  978.             
  979.  key% 
  980. `@              
  981.  1        : 
  982. sel_all(window%)          : 
  983.               
  984.                 dummy%=-1
  985. cC                
  986. copyiconsel(window%,dummy%,0)           : 
  987.               
  988.                 dummy%=-1
  989. fC                
  990. copyiconsel(window%,dummy%,2)           : 
  991. g@              
  992.  5       : 
  993. iced_start(window%,-1)     : 
  994.               
  995. iC                
  996. sel_get(window%)                        : 
  997. j&                
  998.  NrSelected%>=2 
  999. k$                  
  1000. frame_fillwin
  1001. l<                  
  1002. createwinmenu(window%,FrameW%,-80,80)
  1003.                 
  1004.               
  1005. oC                
  1006. sel_get(window%)                        : 
  1007. p&                
  1008.  NrSelected%>=2 
  1009. q<                  
  1010. createwinmenu(window%,AlignW%,-80,80)
  1011.                 
  1012.               
  1013. tC                
  1014. sel_get(window%)                        : 
  1015. u&                
  1016.  NrSelected%>=2 
  1017. v<                  
  1018. createwinmenu(window%,SpaceW%,-80,80)
  1019.                 
  1020.               
  1021.                 dummy%=-1
  1022. zC                
  1023. copyiconsel(window%,dummy%,3)           : 
  1024. {D              
  1025.  17,&1A2 : 
  1026. closetemplate(no%)         : 
  1027.  ^Q,^F2
  1028.               
  1029.                 dummy%=-1
  1030. ~C                
  1031. copyiconsel(window%,dummy%,4)           : 
  1032. @              
  1033.  20      : 
  1034. iced_start(window%,-4)     : 
  1035.               
  1036.                 dummy%=-1
  1037. C                
  1038. copyiconsel(window%,dummy%,1)           : 
  1039. @              
  1040.  23      : 
  1041. wined_fillwin(window%)     : 
  1042. @              
  1043.  24      : 
  1044. deleteiconsel(window%,-1)  : 
  1045. @              
  1046.  26      : 
  1047. sel_clear(window%,-1)      : 
  1048. ;              
  1049.  &18C,&18D,&18E,&18F,&19C,&19D,&19E,&19F
  1050. %                
  1051. sel_get(window%)
  1052. %                
  1053.  NrSelected%>0 
  1054. ?                  
  1055. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  1056. '                  
  1057.  Grid_PosLock% 
  1058. )                    xstep%=Grid_PosX%
  1059. )                    ystep%=Grid_PosY%
  1060.                   
  1061. *                    
  1062.  Grid_SizeLock% 
  1063. ,                      xstep%=Grid_SizeX%
  1064. ,                      ystep%=Grid_SizeY%
  1065.                     
  1066. +                      xstep%=PixToOS_X%
  1067. +                      ystep%=PixToOS_Y%
  1068.                     
  1069.                   
  1070. &                  
  1071.  (key% 
  1072.  &F) 
  1073. *                    
  1074.  &C : dx%=-xstep%
  1075. )                    
  1076.  &D : dx%=xstep%
  1077. *                    
  1078.  &E : dy%=-ystep%
  1079. )                    
  1080.  &F : dy%=ystep%
  1081.                   
  1082. $                  
  1083.  key% 
  1084.  &10 
  1085. !                    dx%=dx%*4
  1086. !                    dy%=dy%*4
  1087.                   
  1088.                    xmin%+=dx%
  1089.                    xmax%+=dx%
  1090.                    ymin%+=dy%
  1091.                    ymax%+=dy%
  1092. M                  
  1093. moveresize(window%,-1,window%,xmin%,ymin%,xmax%,ymax%)
  1094.                 
  1095. 2              
  1096.     : 
  1097.  "Wimp_ProcessKey",key%
  1098.             
  1099.           
  1100. )            
  1101.  "Wimp_ProcessKey",key%
  1102.           
  1103.       
  1104. loadtemplate(name$,buf%,
  1105.  indir%,
  1106.  free%,spptr%)
  1107.  oldindir%,handle%
  1108.  "Wimp_CloseTemplate" : 
  1109. error(1)
  1110. oldindir%=indir%
  1111. name$=name$+
  1112.  "Wimp_LoadTemplate",,buf%+4,indir%,indir%+free%,Fra%,name$,0 
  1113.  ,,indir%
  1114. free%-=(indir%-oldindir%)
  1115. buf%!68=spptr%
  1116.  buf%!88>0 
  1117.  i%=0 
  1118.  buf%!88
  1119.     f%=buf%!(92+i%*32+16)
  1120.  (f% 
  1121.  &103)=&102 
  1122. #      buf%!(92+i%*32+24)=spptr%
  1123.         
  1124.  "Wimp_CreateWindow",,buf%+4 
  1125.  handle%
  1126. buf%!0=handle%
  1127. =handle%
  1128. menuselect(selection%)
  1129.  adjust%,selinfo%,itemnr%,item%,item$,parentitem%,parentitem$
  1130.  cmd$,i%,j%,minx%,miny%,size,dir%
  1131.  "MenuUtil_Decode",LastMenu%,selection% 
  1132.  ,adjust%,selinfo%
  1133. itemnr%=selinfo%!0
  1134. item%=selinfo%!8
  1135. item$=
  1136. str(selinfo%!12)
  1137. parentitem%=selinfo%!24
  1138.  parentitem%<>0 
  1139.  parentitem$=
  1140. str(selinfo%!28)
  1141.  LastMenu% 
  1142.  MainMenu%
  1143.  item% 
  1144.       
  1145.  item_help%
  1146. ,        
  1147. modulepresent("StrongHelp") 
  1148. C          
  1149.  "Wimp_StartTask","Filer_Run <TemplEd$Dir>.TemplEd"
  1150.         
  1151.           
  1152. dialogue(5,"")
  1153.         
  1154.       
  1155.  item_options%
  1156. $        
  1157. openwindow(OptionsW%,2)
  1158.       
  1159.  item_stats%
  1160.         
  1161. stat_fillwin
  1162. -      
  1163.  item_customsprites%,item_sprview%
  1164.         
  1165.  UserSprites%<>1 
  1166. &          cmd$="Run "+SpriteFname$
  1167. 4          
  1168.  OSversion%>=300 
  1169.  cmd$="Filer_"+cmd$
  1170.           
  1171.  cmd$
  1172.         
  1173.       
  1174.  item_sprreload%
  1175. *        
  1176. loadusersprites(SpriteFname$)
  1177.       
  1178.  item_sprreset%
  1179.          
  1180. loadusersprites("")
  1181.       
  1182.  item_quit%
  1183.         
  1184.  ChangesMade% 
  1185.           
  1186. dialogue(0,"")
  1187.         
  1188.           
  1189. prequit
  1190.         
  1191.         
  1192.  TemplMenu%
  1193.  item% 
  1194.       
  1195.  item_templname%
  1196.         
  1197.  parentitem% 
  1198. !          
  1199.  item_createtempl%
  1200.             
  1201. (item$)>0 
  1202. !              WinBlk%!0=DefW%
  1203. 2              
  1204.  "Wimp_GetWindowInfo",,WinBlk%
  1205. J              $(WinBlk%+76)=item$ : 
  1206.  title bar equal to template name
  1207.               WinBlk%!88=0
  1208. -              
  1209. templ_add(item$,WinBlk%,1)
  1210. /              
  1211. opentemplate(NrTemplates%-1)
  1212.                
  1213. setchanged(
  1214.             
  1215. !          
  1216.  item_renametempl%
  1217.             
  1218. (item$)>0 
  1219.               j%=0
  1220. 0              
  1221.  check if name already exists
  1222. F              
  1223.  (j%<NrTemplates%) 
  1224.  ($(TemplNames%+28*j%)<>item$)
  1225.                 j%+=1
  1226.               
  1227. 4              
  1228.  (j%=NrTemplates%) 
  1229.  DuplNames% 
  1230.                  i%=SelBlk%!0
  1231. .                $(TemplNames%+28*i%)=item$
  1232. &                IconBlk%!0=TemplW%
  1233. !                IconBlk%!4=i%
  1234. 4                
  1235.  "Wimp_GetIconState",,IconBlk%
  1236. O                IconBlk%!16=(IconBlk%!8)+(TemplW_IconX%-8)-16*(11-
  1237. (item$))
  1238. =                dummy%=
  1239. redefineicon(TemplW%,i%,IconBlk%)
  1240.     "                
  1241. setchanged(
  1242.               
  1243. 3                
  1244. complain(
  1245. msg_lookup0("TAEX"))
  1246.               
  1247.             
  1248.           
  1249.  item_copytempl%
  1250.             
  1251. (item$)>0 
  1252. #              
  1253. sel_get(TemplW%)
  1254. 8              WinBlk%!0=TemplHandle%!(4*(SelBlk%!0))
  1255. 2              
  1256.  "Wimp_GetWindowInfo",,WinBlk%
  1257. 0              
  1258.  PaneFlag%?(SelBlk%!(4*i%)) 
  1259. G                WinBlk%!32=WinBlk%!32 
  1260.  (1<<5) : 
  1261.  copy 'Pane' flag
  1262.               
  1263. 5              
  1264. iconrealloc(WinBlk%+60,WinBlk%+76)
  1265. "              
  1266.  WinBlk%!88>0 
  1267. )                
  1268.  i%=0 
  1269.  WinBlk%!88-1
  1270. K                  
  1271. iconrealloc(WinBlk%+92+32*i%+16,WinBlk%+92+32*i%+20)
  1272.                 
  1273.               
  1274. -              
  1275. templ_add(item$,WinBlk%,1)
  1276. /              
  1277. opentemplate(NrTemplates%-1)
  1278.                
  1279. setchanged(
  1280.             
  1281.         
  1282.       
  1283.  item_opentempl%
  1284.         
  1285. sel_get(TemplW%)
  1286. #'        
  1287.  i%=NrSelected%-1 
  1288. $+          
  1289. opentemplate(SelBlk%!(4*i%))
  1290.         
  1291.       
  1292.  item_closetempl%
  1293.         
  1294. sel_get(TemplW%)
  1295. ('        
  1296.  i%=NrSelected%-1 
  1297. ),          
  1298. closetemplate(SelBlk%!(4*i%))
  1299.         
  1300.       
  1301.  item_deletetempl%
  1302.         
  1303.  "Hourglass_On"
  1304.         
  1305. sel_get(TemplW%)
  1306. .'        
  1307.  i%=NrSelected%-1 
  1308. /+          
  1309. templ_delete(SelBlk%!(4*i%))
  1310.         
  1311. 1"        
  1312. sel_clear(TemplW%,-1)
  1313. 2!        LastMenu_Win%=TemplW%
  1314.         LastMenu_Icon%=-1
  1315.         
  1316.  "Hourglass_Off"
  1317.       
  1318.  item_selalltempl%
  1319.         
  1320. sel_all(TemplW%)
  1321. 7!        TemplMenu_Deselect%=
  1322.       
  1323.  item_clearseltempl%
  1324. 9"        
  1325. sel_clear(TemplW%,-1)
  1326. :!        TemplMenu_Deselect%=
  1327.       
  1328.  item_deleteall%
  1329.         
  1330.  ChangesMade% 
  1331.           
  1332. dialogue(1,"")
  1333.         
  1334.           
  1335. templ_deleteall
  1336. @#          LastMenu_Win%=TemplW%
  1337.           LastMenu_Icon%=-1
  1338.         
  1339.       
  1340.  item_sorttempl%
  1341. D"        
  1342. sel_clear(TemplW%,-1)
  1343.         
  1344. templ_sort
  1345.         
  1346. redefinebrowser(
  1347. G!        LastMenu_Win%=TemplW%
  1348.         LastMenu_Icon%=-1
  1349.       
  1350.  item_save%
  1351.         SavingSelection%=
  1352. K&        
  1353. savetemplates(MainFname$)
  1354. L        
  1355. M6    
  1356.  TemplMenu_Deselect% 
  1357. sel_clear(TemplW%,-1)
  1358.  UserMenu%
  1359.  item% 
  1360. PE      
  1361.  item_copyicon%,item_up%,item_down%,item_left%,item_right%
  1362.         
  1363.  item% 
  1364. R'          
  1365.  item_copyicon% : dir%=0
  1366. S'          
  1367.  item_up%       : dir%=1
  1368. T'          
  1369.  item_down%     : dir%=2
  1370. U'          
  1371.  item_left%     : dir%=3
  1372. V'          
  1373.  item_right%    : dir%=4
  1374.         
  1375. X;        
  1376. copyiconsel(LastMenu_Win%,LastMenu_Icon%,dir%)
  1377. Y+      
  1378.  item_iconnr%,item_renumbericon%
  1379. Z7        
  1380.  item%=item_iconnr% 
  1381.  NextIconNr%=
  1382. (item$)
  1383. [#        
  1384. sel_get(LastMenu_Win%)
  1385.         
  1386.  NrSelected% 
  1387.           
  1388. ^;            
  1389. renumbericon(LastMenu_Win%,LastMenu_Icon%)
  1390. _*            LastMenu_Icon%=NextIconNr%
  1391.             NextIconNr%+=1
  1392.           
  1393. b6            
  1394. renumbericon(LastMenu_Win%,SelBlk%!0)
  1395.           
  1396. d/            
  1397. renumbericonsel(LastMenu_Win%)
  1398.         
  1399.       
  1400.  item_deleteicon%
  1401. g8        
  1402. deleteiconsel(LastMenu_Win%,LastMenu_Icon%)
  1403.       
  1404.  item_editicon%
  1405. i5        
  1406. iced_start(LastMenu_Win%,LastMenu_Icon%)
  1407.       
  1408.  item_minsize%
  1409. k<        
  1410. minimizeiconsel(LastMenu_Win%,LastMenu_Icon%,0)
  1411.       
  1412.  item_centericon%
  1413. m:        
  1414. centericonsel(LastMenu_Win%,LastMenu_Icon%,0)
  1415.       
  1416.  item_samesize%
  1417. o<        
  1418. samesizeiconsel(LastMenu_Win%,LastMenu_Icon%,0)
  1419. p,      
  1420.  item_both%,item_xdim%,item_ydim%
  1421.         
  1422.  parentitem% 
  1423.           
  1424.  item_minsize%
  1425. sF            
  1426. minimizeiconsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1427. t           
  1428.  item_centericon%
  1429. uD            
  1430. centericonsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1431.           
  1432.  item_samesize%
  1433. wF            
  1434. samesizeiconsel(LastMenu_Win%,LastMenu_Icon%,itemnr%)
  1435.         
  1436.       
  1437.  item_selallicons%
  1438. z#        
  1439. sel_all(LastMenu_Win%)
  1440.       
  1441.  item_clearselicons%
  1442. |(        
  1443. sel_clear(LastMenu_Win%,-1)
  1444.       
  1445.  item_editwindow%
  1446. ~)        
  1447. wined_fillwin(LastMenu_Win%)
  1448.       
  1449.  item_edittitle%
  1450. )        
  1451. iced_start(LastMenu_Win%,-4)
  1452.       
  1453.  item_tidy1%
  1454. 5        LastMenu_Win%=
  1455. tidyicons(LastMenu_Win%,1)
  1456.       
  1457.  item_tidy2%
  1458. 5        LastMenu_Win%=
  1459. tidyicons(LastMenu_Win%,2)
  1460.       
  1461.  item_tidy3%
  1462. 5        LastMenu_Win%=
  1463. tidyicons(LastMenu_Win%,3)
  1464.       
  1465.  item_tidy4%
  1466. 5        LastMenu_Win%=
  1467. tidyicons(LastMenu_Win%,4)
  1468.       
  1469.  item_tidy5%
  1470. 5        LastMenu_Win%=
  1471. tidyicons(LastMenu_Win%,5)
  1472.       
  1473.  item_centerwin%
  1474. (        
  1475. openwindow(LastMenu_Win%,1)
  1476.       
  1477.  item_wimparea%
  1478. 2        
  1479. window_setspritearea(LastMenu_Win%,1)
  1480.       
  1481.  item_customarea%
  1482. =        
  1483. window_setspritearea(LastMenu_Win%,UserSprites%)
  1484.       
  1485.  item_closewin%
  1486. 9        
  1487. closetemplate(
  1488. whichtemplate(LastMenu_Win%))
  1489.       
  1490.  item_createicon%
  1491. $        
  1492. openwindow(PaletteW%,0)
  1493.         
  1494.  IcButtonMenu%
  1495.     IcEd_Button%=itemnr%
  1496. 4    
  1497. seticontext(4,$(IcButton%+20*IcEd_Button%))
  1498.  WinButtonMenu%
  1499.     WinEd_Button%=itemnr%
  1500. 6    
  1501. seticontext(6,$(WinButton%+20*WinEd_Button%))
  1502.  EsgMenu%
  1503.     IcEd_Esg%=
  1504. item$,2))
  1505. $    
  1506. seticontext(5,
  1507. (IcEd_Esg%))
  1508.  ColourMenu%
  1509.  item$="None" 
  1510.       j%=255
  1511.         
  1512.       j%=
  1513. (item$)
  1514.         
  1515.  LastMenu_Win% 
  1516.       
  1517.  IcEdW%
  1518.         
  1519.  LastMenu_Icon% 
  1520.           
  1521.             IcEd_Fgcol%=j%
  1522. #            
  1523. setcolourbox(0,j%)
  1524.           
  1525.             IcEd_Bgcol%=j%
  1526. #            
  1527. setcolourbox(1,j%)
  1528.         
  1529.       
  1530.  WinEdW%
  1531. &        i%=(LastMenu_Icon%-27) 
  1532.         WinEd_Col%(i%)=j%
  1533. "        
  1534. setcolourbox(2+i%,j%)
  1535.         
  1536.  FontMenu%
  1537. (parentitem$)>0 
  1538.       
  1539.  item$="(Regular)" 
  1540. "        IcEd_Font$=parentitem$
  1541.       
  1542. ,        IcEd_Font$=parentitem$+"."+item$
  1543.       
  1544. %      
  1545. seticontext(19,IcEd_Font$)
  1546.         
  1547.  FontSizemenu%
  1548.     size=
  1549. (item$)
  1550.  size>0 
  1551.       
  1552.  LastMenu_Icon%=48 
  1553.         IcEd_Xsize=size
  1554. .        
  1555. seticontext(20,
  1556. (IcEd_Xsize),4))
  1557. (        
  1558. iconselected(IcEdW%,53) 
  1559. #          IcEd_Ysize=IcEd_Xsize
  1560. 0          
  1561. seticontext(21,
  1562. (IcEd_Ysize),4))
  1563.         
  1564.       
  1565.         IcEd_Ysize=size
  1566. .        
  1567. seticontext(21,
  1568. (IcEd_Ysize),4))
  1569.       
  1570.         
  1571.  Updatemenu%
  1572.  item% 
  1573. 1      
  1574.  item_updbt%   : 
  1575. iced_readwin(&F<<12)
  1576. 2      
  1577.  item_updesg%  : 
  1578. iced_readwin(&1F<<16)
  1579. :      
  1580.  item_updfg%   : 
  1581. iced_readwin((&F<<24)+(1<<6))
  1582. :      
  1583.  item_updbg%   : 
  1584. iced_readwin((&F<<28)+(1<<6))
  1585. ;      
  1586.  item_updfont% : 
  1587. iced_readwin((&FF<<24)+(1<<6))
  1588. 7      
  1589.  item_updrest% : 
  1590. iced_readwin(&EFC+(1<<22))
  1591. /      
  1592.  item_updbo%:  : 
  1593. iced_readwin(1<<2)
  1594. /      
  1595.  item_updfi%:  : 
  1596. iced_readwin(1<<5)
  1597. /      
  1598.  item_updhc%:  : 
  1599. iced_readwin(1<<3)
  1600. /      
  1601.  item_updvc%:  : 
  1602. iced_readwin(1<<4)
  1603. /      
  1604.  item_updrj%:  : 
  1605. iced_readwin(1<<9)
  1606. /      
  1607.  item_updnh%:  : 
  1608. iced_readwin(1<<7)
  1609. 0      
  1610.  item_updaa%:  : 
  1611. iced_readwin(1<<10)
  1612. 0      
  1613.  item_updhs%:  : 
  1614. iced_readwin(1<<11)
  1615. 0      
  1616.  item_updsh%:  : 
  1617. iced_readwin(1<<22)
  1618.         
  1619.  LastMenu_Icon%=10 
  1620.       
  1621. closewindow(IcEdW%)
  1622. !      
  1623. setcaret(IcEd_Win%,-1)
  1624.       adjust%=
  1625.         
  1626.  adjust% 
  1627. createmenu(LastMenu_X%,LastMenu_Y%,LastMenu_Win%,LastMenu_Icon%)
  1628.   LastMenu%=-1
  1629. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1630.  key%,dclick%
  1631. key%=0
  1632. dclick%=
  1633.  -1) 
  1634.  key%+=1 : 
  1635.  bit 0 -> Shift key
  1636.  -2) 
  1637.  key%+=2 : 
  1638.  bit 1 -> Ctrl key
  1639.  -3) 
  1640.  key%+=4 : 
  1641.  bit 2 -> Alt key
  1642. +TimedDrag_Enabled%=(key%=0)
  1643. (icon%>=-1)
  1644.  button%>256 
  1645. @  button%=button%>>8 : 
  1646.  clicked on icon with button type 10
  1647.  key% 
  1648.  0 : 
  1649.  mouse button, no key
  1650.  button%>0 
  1651. 4      dclick%=(
  1652. -ThisClickTime%)<DclickInterval%
  1653. A      dclick%=dclick% 
  1654.  (ThisClickButton%=button%) 
  1655.  (no%>=0)
  1656. J      dclick%=dclick% 
  1657. (ThisClickX%-xpos%)+
  1658. (ThisClickY%-ypos%))<32
  1659.       ThisClickTime%=
  1660.       ThisClickX%=xpos%
  1661.       ThisClickY%=ypos%
  1662. "      ThisClickButton%=button%
  1663.         
  1664.  button% 
  1665.       
  1666.         
  1667.  icon% 
  1668.           
  1669. 7            
  1670.  dclick% 
  1671.  TrapDclick% 
  1672.  (button%=4) 
  1673. ,              
  1674. iced_start(window%,icon%)
  1675.             
  1676.           
  1677.     4            
  1678.  button%=4 
  1679. sel_clear(window%,-1)
  1680. 7            
  1681.  dclick% 
  1682.  TrapDclick% 
  1683.  (button%=4) 
  1684. )              
  1685. wined_fillwin(window%)
  1686.             
  1687. &              
  1688. dragselect(button%)
  1689. 2              
  1690.  no%>=0 
  1691. setcaret(window%,-1)
  1692.             
  1693.           
  1694.             
  1695.  icon%>=0 
  1696.               
  1697.  button%=1 
  1698. -                
  1699.  toggle "selected" state
  1700. '                ScrapBlk%!0=window%
  1701. %                ScrapBlk%!4=icon%
  1702. 5                
  1703.  "Wimp_GetIconState",,ScrapBlk%
  1704. 2                
  1705.  ((ScrapBlk%!24)>>12) 
  1706. M                  
  1707.  4,9      : 
  1708.  selecting useless for these button types
  1709. ;                  
  1710.  5,7,8,11 : 
  1711.  selecting done by wimp
  1712. <                  
  1713. seticonstate(window%,icon%,1<<21,0)
  1714.                 
  1715.               
  1716. (                
  1717.  "exclusive" select
  1718. -                
  1719. sel_clear(window%,icon%)
  1720. 6                
  1721. iconselected(window%,icon%) 
  1722.  2                  
  1723. selecticon(window%,icon%,1)
  1724.                 
  1725.               
  1726. #9              
  1727.  dclick% 
  1728.  TrapDclick% 
  1729.  (button%=4) 
  1730. $.                
  1731. iced_start(window%,icon%)
  1732.               
  1733. &(                
  1734. dragselect(button%)
  1735. '4                
  1736.  no%>=0 
  1737. setcaret(window%,-1)
  1738.               
  1739.             
  1740.         
  1741. +        
  1742.  1 : 
  1743.  shift + mouse button
  1744.  button% 
  1745.       
  1746. /,        
  1747.  no%>=0 
  1748. setcaret(window%,-1)
  1749. 0&        
  1750.  (no%>=0) 
  1751.  (button%=4) 
  1752. 13          
  1753. starticondrag(button%,window%,icon%)
  1754.         
  1755.       
  1756. 41        
  1757.  no%>=0 
  1758. iced_start(window%,icon%)
  1759. 5        
  1760.  2 : 
  1761.  ctrl + mouse button
  1762.  button% 
  1763.       
  1764.         
  1765.  no%>=0 
  1766. :#          
  1767. setcaret(window%,-1)
  1768. ;)          
  1769. startwindowresize(window%)
  1770.         
  1771.       
  1772.         
  1773.  no%>=0 
  1774.           
  1775.  icon%=-4 
  1776. @*            
  1777. iced_start(window%,icon%)
  1778.           
  1779. B'            
  1780. wined_fillwin(window%)
  1781.           
  1782.         
  1783.       
  1784.         
  1785.  no%>=0 
  1786. G#          
  1787. setcaret(window%,-1)
  1788. H'          
  1789. startwindowmove(window%)
  1790.         
  1791. J        
  1792.  4 : 
  1793.  alt + mouse button
  1794.  button% 
  1795.       
  1796. N%        
  1797.  (icon%>=0) 
  1798.  (no%>=0) 
  1799. O*          
  1800. renumbericon(window%,icon%)
  1801. P.          
  1802.  NextIconNr%>0 
  1803.  NextIconNr%-=1
  1804.         
  1805.       
  1806. S%        
  1807.  (icon%>=0) 
  1808.  (no%>=0) 
  1809. T*          
  1810. renumbericon(window%,icon%)
  1811.           NextIconNr%+=1
  1812.         
  1813. W        
  1814.  6 : 
  1815.  alt + ctrl + mouse button
  1816.  button% 
  1817.       
  1818. [6        
  1819.  (no%>=0) 
  1820. startworkarearesize(window%)
  1821. \        
  1822.  (button%>0) 
  1823.       
  1824.  Support% 
  1825. `%        
  1826.  1 : 
  1827.  support Interface
  1828.           
  1829.  invert icon
  1830. b!          ScrapBlk%!8=button%
  1831. c"          ScrapBlk%!12=window%
  1832. d           ScrapBlk%!16=icon%
  1833. e-          
  1834.  "Wimp_BorderIcon",,ScrapBlk%
  1835.           
  1836.  back to normal
  1837.           ScrapBlk%!8=0
  1838. h"          ScrapBlk%!12=window%
  1839. i           ScrapBlk%!16=icon%
  1840. j-          
  1841.  "Wimp_BorderIcon",,ScrapBlk%
  1842.         
  1843.  2 : 
  1844.  support AEH
  1845. l!          ScrapBlk%!8=button%
  1846. m"          ScrapBlk%!12=window%
  1847. n           ScrapBlk%!16=icon%
  1848. o,          
  1849.  "AEH_RedrawIcon",,ScrapBlk%
  1850. p$          
  1851.  "AEH_ReleaseIcon",0
  1852. q#        
  1853.  3 : 
  1854.  support WimpExt
  1855. r3          
  1856.  "WimpExt_SlabIcon",,,window%,icon%
  1857.       
  1858. t        
  1859. click(xpos%,ypos%,button%,window%,icon%,wimpclick%)
  1860.  no%,key%
  1861. z"Mbuttons_Released%=(button%=0)
  1862. TimedDrag_Enabled%=
  1863. whichtemplate(window%)
  1864.  button%=2 
  1865.  "steal" clicks with Menu if Shift, Ctrl or Alt pressed
  1866.  "OS_Byte",121,0 
  1867.  ,key%
  1868.  key%>=3 
  1869. =    
  1870.  wimpclick% 
  1871. createmenu(xpos%,ypos%,window%,icon%)
  1872. F    
  1873.  no%<>-1 
  1874. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1875.  no%<>-1 
  1876. :    
  1877. editaction(xpos%,ypos%,button%,window%,icon%,no%)
  1878. D    
  1879.  wimpclick% 
  1880. iconclick(xpos%,ypos%,button%,window%,icon%)
  1881. iconclick(xpos%,ypos%,button%,window%,icon%)
  1882.  select%,menu%,adjust%,i%,j%,xsize%,ysize%,up%,lo%
  1883. select%=(button%=4)
  1884. menu%=(button%=2)
  1885. adjust%=(button%=1)
  1886.  window% 
  1887.  select% 
  1888.       
  1889. redefinebrowser(
  1890.        
  1891. openwindow(TemplW%,3)
  1892. 4      
  1893.  IcInfo_Active% 
  1894. openwindow(IcInfoW%,4)
  1895.         
  1896.  IcEdW%
  1897. 6    
  1898. iced_click(xpos%,ypos%,select%,adjust%,icon%)
  1899.  WinEdW%
  1900. 7    
  1901. wined_click(xpos%,ypos%,select%,adjust%,icon%)
  1902.  StatW%
  1903. !    
  1904.  (icon%=1) 
  1905.  (icon%=2) 
  1906. "      Stats_Decimal%=(icon%=1)
  1907. %      
  1908. selecticon(StatW%,icon%,1)
  1909.       
  1910. stat_fillwin
  1911.         
  1912.  TemplW%
  1913. ,    
  1914.  (select% 
  1915.  adjust%) 
  1916.  (icon%>=0) 
  1917. ,      ScrapBlk%!0=TemplHandle%!(4*icon%)
  1918. -      
  1919.  "Wimp_GetWindowState",,ScrapBlk%
  1920. $      
  1921.  ScrapBlk%!32 
  1922.  (1<<16) 
  1923. !        
  1924. closetemplate(icon%)
  1925.       
  1926.          
  1927. opentemplate(icon%)
  1928.       
  1929. &      
  1930. selecticon(TemplW%,icon%,0)
  1931.         
  1932.      
  1933.  select% 
  1934.  (icon%=-1) 
  1935.        
  1936. sel_clear(TemplW%,-1)
  1937.         
  1938. '    
  1939.  (button%=16) 
  1940.  (button%=64) 
  1941. !      
  1942. dragselect(button%>>4)
  1943.         
  1944.  SaveW%
  1945.  icon% 
  1946.       
  1947.         
  1948.  Exporting% 
  1949. ,          
  1950. exporttemplates($(FileName%))
  1951.         
  1952. "          
  1953.  SavingSelection% 
  1954. &            SelFname$=$(FileName%)
  1955. )            
  1956. savetemplates(SelFname$)
  1957.           
  1958. +            
  1959. setmainfname($(FileName%))
  1960. *            
  1961. savetemplates(MainFname$)
  1962.           
  1963.         
  1964. $        
  1965.  "Wimp_CreateMenu",,-1
  1966.       
  1967.          
  1968.  (button%>>4) 
  1969. $          
  1970. startsavedrag(SaveW%)
  1971.         
  1972.         
  1973.  ExportW%
  1974.  icon% 
  1975.       
  1976. -        
  1977. export_savenames($(ExportName%))
  1978.       
  1979.          
  1980.  (button%>>4) 
  1981. &          
  1982. startsavedrag(ExportW%)
  1983.         
  1984.       
  1985.  3,4,5
  1986. $        
  1987. export_settype(icon%-3)
  1988.         
  1989.  AlignW%
  1990.  icon% 
  1991.       
  1992. &        
  1993. alignicons(LastMenu_Win%)
  1994. 4        
  1995.  adjust%) 
  1996.  "Wimp_CreateMenu",,-1
  1997.       
  1998.         
  1999. align_shadeicons
  2000.         
  2001.  SpaceW%
  2002.  icon% 
  2003.       
  2004. /        SpaceOut_Space%=
  2005. ($(IconText%(18)))
  2006. %        up%=(adjust% 
  2007.  (icon%=7))
  2008. :        
  2009. changevar(SpaceOut_Space%,4,up%,-512,512) 
  2010. 1          
  2011. seticontext(18,
  2012. (SpaceOut_Space%))
  2013. "          
  2014. setcaret(SpaceW%,6)
  2015.         
  2016.      
  2017.         
  2018. space_shadeicons
  2019. (        
  2020.  icon%=8 
  2021. setcaret(-1,-1)
  2022.       
  2023. &        
  2024. spaceicons(LastMenu_Win%)
  2025. 4        
  2026.  adjust%) 
  2027.  "Wimp_CreateMenu",,-1
  2028.         
  2029.  FrameW%
  2030.  icon% 
  2031.       
  2032. -        Frame_IconNo%=
  2033. ($(IconText%(32)))
  2034. %        up%=(adjust% 
  2035.  (icon%=9))
  2036. 5        
  2037. changevar(Frame_IconNo%,1,up%,0,512) 
  2038. /          
  2039. seticontext(32,
  2040. (Frame_IconNo%))
  2041. "          
  2042. setcaret(FrameW%,7)
  2043.         
  2044.       
  2045.  12,13
  2046. ,        Frame_Space%=
  2047. ($(IconText%(33)))
  2048. &        up%=(adjust% 
  2049.  (icon%=13))
  2050. 4        
  2051. changevar(Frame_Space%,4,up%,0,512) 
  2052. .          
  2053. seticontext(33,
  2054. (Frame_Space%))
  2055. #          
  2056. setcaret(FrameW%,11)
  2057.         
  2058.       
  2059.  18,19
  2060. .        Frame_LabelNo%=
  2061. ($(IconText%(34)))
  2062. &        up%=(adjust% 
  2063.  (icon%=17))
  2064. 6        
  2065. changevar(Frame_LabelNo%,1,up%,0,512) 
  2066. 0          
  2067. seticontext(34,
  2068. (Frame_LabelNo%))
  2069. #          
  2070. setcaret(FrameW%,17)
  2071.         
  2072.       
  2073.  23,24
  2074. 0        Frame_LeftSpace%=
  2075. ($(IconText%(35)))
  2076. &        up%=(adjust% 
  2077.  (icon%=24))
  2078. 8        
  2079. changevar(Frame_LeftSpace%,4,up%,0,512) 
  2080. 2          
  2081. seticontext(35,
  2082. (Frame_LeftSpace%))
  2083. #          
  2084. setcaret(FrameW%,22)
  2085.         
  2086.       
  2087. 4        
  2088.  adjust%) 
  2089.  "Wimp_CreateMenu",,-1
  2090. &        
  2091. frameicons(LastMenu_Win%)
  2092.       
  2093.  5,6,15,16,20,21
  2094. 4        
  2095.  adjust% 
  2096. selecticon(FrameW%,icon%,1)
  2097.         
  2098. frame_shadeicons
  2099.         
  2100.  WorkW%
  2101.  icon%<=26 
  2102. +      
  2103.  (icon%>=9) 
  2104.  ((icon% 
  2105.  3)<>1) 
  2106. "        
  2107.  click on arrow icons
  2108. )        up%=((icon% 
  2109.  3)=2) 
  2110.  adjust%
  2111.         i%=(icon%-9) 
  2112. %        j%=
  2113. ($(IconText%(12+i%)))
  2114.         
  2115.  i%<2 
  2116.           lo%=-10000
  2117.         
  2118. 7          lo%=0 : 
  2119.  "size" field, can't be negative
  2120.         
  2121. .        
  2122. changevar(j%,4,up%,lo%,10000) 
  2123. '          
  2124. seticontext(12+i%,
  2125. (j%))
  2126. '          
  2127. setcaret(WorkW%,3*i%+10)
  2128.         
  2129.       
  2130.                  
  2131. #!      WinBlk%!0=LastMenu_Win%
  2132. $+      
  2133.  "Wimp_GetWindowState",,WinBlk%
  2134.       
  2135.  icon% 
  2136.         
  2137.  27,28
  2138. '?          xsize%=WinBlk%!12-WinBlk%!4+WinBlk%!20-WinBlk%!44
  2139. (?          ysize%=WinBlk%!16-WinBlk%!8-WinBlk%!24+WinBlk%!56
  2140.           
  2141.  icon%=27 
  2142. *.            
  2143. seticontext(12,
  2144. (WinBlk%!44))
  2145. +.            
  2146. seticontext(13,
  2147. (WinBlk%!56))
  2148. ,*            
  2149. seticontext(14,
  2150. (xsize%))
  2151. -*            
  2152. seticontext(15,
  2153. (ysize%))
  2154. .$            
  2155. setcaret(WorkW%,16)
  2156.           
  2157. 0*            
  2158. seticontext(16,
  2159. (xsize%))
  2160. 1*            
  2161. seticontext(17,
  2162. (ysize%))
  2163. 2$            
  2164. setcaret(WorkW%,22)
  2165.           
  2166.         
  2167. 5"          
  2168. seticontext(12,"0")
  2169. 6"          
  2170. seticontext(13,"0")
  2171. 7%          
  2172. seticontext(14,"1236")
  2173. 8$          
  2174. seticontext(15,"936")
  2175. 9"          
  2176. seticontext(16,"0")
  2177. :"          
  2178. seticontext(17,"0")
  2179. ;"          
  2180. setcaret(WorkW%,16)
  2181.         
  2182.           
  2183. setworkarea
  2184. >6          
  2185.  adjust%) 
  2186.  "Wimp_CreateMenu",,-1
  2187.         
  2188.       
  2189. A        
  2190.  OptPaneW%
  2191.  icon% 
  2192. D*      
  2193.  8  : TrapDclick%=
  2194.  TrapDclick%
  2195.       
  2196. F.        
  2197. iconselected(OptPaneW%,icon%) 
  2198.           
  2199. support(1)
  2200.         
  2201.           
  2202. support(0)
  2203.         
  2204.       
  2205. L.        
  2206. iconselected(OptPaneW%,icon%) 
  2207.           
  2208. support(2)
  2209.         
  2210.           
  2211. support(0)
  2212.         
  2213.       
  2214. R.        
  2215. iconselected(OptPaneW%,icon%) 
  2216.           
  2217. support(3)
  2218.         
  2219.           
  2220. support(0)
  2221.         
  2222. W(      
  2223.  11 : DuplNames%=
  2224.  DuplNames%
  2225.       
  2226.         Hatch%=
  2227.  Hatch%
  2228.         
  2229. redrawall
  2230.       
  2231. \+        IcInfo_Active%=
  2232.  IcInfo_Active%
  2233.         
  2234.  IcInfo_Active% 
  2235. ^%          
  2236. openwindow(IcInfoW%,4)
  2237.         
  2238. `$          
  2239. closewindow(IcInfoW%)
  2240.         
  2241. b4      
  2242.  14 : Save_Unselected%=
  2243.  Save_Unselected%
  2244. c0      
  2245.  15 : DeleteOutside%=
  2246.  DeleteOutside%
  2247. d2      
  2248.  35 : IgnoreDeskFont%=
  2249.  IgnoreDeskFont%
  2250. e0      
  2251.  16 : Grid_SizeLock%=
  2252.  Grid_SizeLock%
  2253.       
  2254.  18,20
  2255. g&        up%=(adjust% 
  2256.  (icon%=20))
  2257. hD        
  2258. changevar(Grid_SizeX%,PixToOS_X%,up%,PixToOS_X%,64) 
  2259. i-          
  2260. seticontext(28,
  2261. (Grid_SizeX%))
  2262.         
  2263.       
  2264.  22,24
  2265. l&        up%=(adjust% 
  2266.  (icon%=24))
  2267. mD        
  2268. changevar(Grid_SizeY%,PixToOS_Y%,up%,PixToOS_Y%,64) 
  2269. n-          
  2270. seticontext(29,
  2271. (Grid_SizeY%))
  2272.         
  2273. p.      
  2274.  25 : Grid_PosLock%=
  2275.  Grid_PosLock%
  2276.       
  2277.  27,29
  2278. r&        up%=(adjust% 
  2279.  (icon%=29))
  2280. sC        
  2281. changevar(Grid_PosX%,PixToOS_X%,up%,PixToOS_X%,64) 
  2282. t,          
  2283. seticontext(30,
  2284. (Grid_PosX%))
  2285.         
  2286.       
  2287.  31,33
  2288. w&        up%=(adjust% 
  2289.  (icon%=33))
  2290. xC        
  2291. changevar(Grid_PosY%,PixToOS_Y%,up%,PixToOS_Y%,64) 
  2292. y,          
  2293. seticontext(31,
  2294. (Grid_PosY%))
  2295.         
  2296. {        
  2297.  OptionsW%
  2298.  icon% 
  2299.       
  2300.         
  2301. setup_save
  2302. #        
  2303. closewindow(OptionsW%)
  2304.       
  2305. #        
  2306. closewindow(OptionsW%)
  2307.         
  2308.  DialW%
  2309.      
  2310.  "Wimp_CreateMenu",,-1
  2311.  LastDialogue% 
  2312.       
  2313. ,        
  2314.  program quit with changes made
  2315.         
  2316.  icon% 
  2317.           
  2318. 2            
  2319.  "Wimp_GetPointerInfo",,PtrInfo%
  2320. '            $(FileName%)=MainFname$
  2321. )            $SaveFileIcon%="file_fec"
  2322. "            SavingSelection%=
  2323.             Exporting%=
  2324.              QuitAfterSave%=
  2325. 1            
  2326. createwinmenu(-1,SaveW%,-126,56)
  2327.           
  2328.             
  2329. prequit
  2330.         
  2331.       
  2332. *        
  2333.  delete all with changes made
  2334. (        
  2335.  icon%=1 
  2336. templ_deleteall
  2337.       
  2338. -        
  2339.  load new file with changes made
  2340.         
  2341.  icon%=1 
  2342.           
  2343. templ_deleteall
  2344. *          
  2345. templ_loadfile(NewFname$,1)
  2346. &          
  2347. setmainfname(NewFname$)
  2348.         
  2349.       
  2350. 1        
  2351.  exit from desktop with changes made
  2352.         
  2353.  icon% 
  2354.           
  2355.              
  2356. templ_deleteall
  2357. A            
  2358.  resume prequit procedure (code copied from PRM)
  2359. 5            
  2360.  "Wimp_GetCaretPosition",,ScrapBlk%
  2361. !            ScrapBlk%!24=&1FC
  2362. @            
  2363.  "Wimp_SendMessage",8,ScrapBlk%,PreQuitSender%
  2364.         
  2365.         
  2366. wined_click(xpos%,ypos%,select%,adjust%,icon%)
  2367.  up%,i%,gcol%
  2368.  icon% 
  2369. wined_readwin
  2370. wined_readwin
  2371. closewindow(WinEdW%)
  2372.      
  2373. setcaret(WinEd_Win%,-1)
  2374. closewindow(WinEdW%)
  2375.      
  2376. setcaret(WinEd_Win%,-1)
  2377. '    
  2378. iconselected(WinEdW%,20) 
  2379. ;      
  2380. selecticon(WinEdW%,14,
  2381. iconselected(WinEdW%,13))
  2382.         
  2383. '    
  2384. iconselected(WinEdW%,20) 
  2385. ;      
  2386. selecticon(WinEdW%,13,
  2387. iconselected(WinEdW%,14))
  2388.         
  2389.  15,17,19,20
  2390.      
  2391. wined_shadeicons(icon%)
  2392.  23,27,31,35,39,43,47,51
  2393. .    
  2394. createmenu(xpos%,ypos%,WinEdW%,icon%)
  2395.  22,24
  2396. "    up%=(adjust% 
  2397.  (icon%=24))
  2398. 0    
  2399. changevar(WinEd_Button%,1,up%,0,15) 
  2400. 8      
  2401. seticontext(6,$(WinButton%+20*WinEd_Button%))
  2402.         
  2403.     WinEd_Col%(0)=7
  2404.     WinEd_Col%(1)=2
  2405.     WinEd_Col%(2)=7
  2406.     WinEd_Col%(3)=1
  2407.     WinEd_Col%(4)=3
  2408.     WinEd_Col%(5)=1
  2409.     WinEd_Col%(6)=12
  2410.  i%=0 
  2411. ,      
  2412. setcolourbox(2+i%,WinEd_Col%(i%))
  2413. 7    
  2414.  (icon%>=26) 
  2415.  (icon%<=52) 
  2416.  ((icon% 
  2417.  2)=0) 
  2418. '      up%=((icon% 
  2419.  4)=0) 
  2420.  adjust%
  2421.       i%=(icon%-26) 
  2422. (      gcol%=
  2423. iconselected(WinEdW%,9)
  2424. ;      
  2425. changecolourbox(2+i%,WinEd_Col%(i%),1,up%,gcol%)
  2426.         
  2427. iced_click(xpos%,ypos%,select%,adjust%,icon%)
  2428.  up%,l%
  2429.  icon% 
  2430. .    
  2431.  adjust% 
  2432. iconselected(IcEdW%,14) 
  2433. /      
  2434.  minimize number in 'Max size' field
  2435. &      
  2436. iconselected(IcEdW%,12) 
  2437. #          l%=
  2438. ($(IconText%(0)))
  2439.       
  2440. (        
  2441. iconselected(IcEdW%,13) 
  2442. #          l%=
  2443. ($(IconText%(1)))
  2444.         
  2445.       
  2446. !      
  2447. seticontext(3,
  2448. (l%+1))
  2449.         
  2450. iced_readwin(-1)
  2451. iced_readwin(-1)
  2452. closewindow(IcEdW%)
  2453. setcaret(IcEd_Win%,-1)
  2454. closewindow(IcEdW%)
  2455. setcaret(IcEd_Win%,-1)
  2456.  12,13,14,41,53
  2457. iced_shadeicons(icon%)
  2458.  28,31,34,37,45,46,48,51
  2459. -    
  2460. createmenu(xpos%,ypos%,IcEdW%,icon%)
  2461.  27,29
  2462. "    up%=(adjust% 
  2463.  (icon%=29))
  2464. /    
  2465. changevar(IcEd_Button%,1,up%,0,15) 
  2466. 6      
  2467. seticontext(4,$(IcButton%+20*IcEd_Button%))
  2468.         
  2469.  30,32
  2470. "    up%=(adjust% 
  2471.  (icon%=32))
  2472. ,    
  2473. changevar(IcEd_Esg%,1,up%,0,31) 
  2474. &      
  2475. seticontext(5,
  2476. (IcEd_Esg%))
  2477.         
  2478.  33,35
  2479. "    up%=(adjust% 
  2480.  (icon%=35))
  2481. /    
  2482. changecolourbox(0,IcEd_Fgcol%,1,up%,0)
  2483.  36,38
  2484.     "    up%=(adjust% 
  2485.  (icon%=38))
  2486. /    
  2487. changecolourbox(1,IcEd_Bgcol%,1,up%,0)
  2488.  47,49
  2489. ;    
  2490.  (adjust% 
  2491.  (icon%=47)) 
  2492.  (select% 
  2493.  (icon%=49)) 
  2494.       
  2495.  IcEd_Xsize<998 
  2496.         IcEd_Xsize+=2
  2497. .        
  2498. seticontext(20,
  2499. (IcEd_Xsize),4))
  2500. (        
  2501. iconselected(IcEdW%,53) 
  2502. #          IcEd_Ysize=IcEd_Xsize
  2503. 0          
  2504. seticontext(21,
  2505. (IcEd_Ysize),4))
  2506.         
  2507.       
  2508.         
  2509.       
  2510.  IcEd_Xsize>2 
  2511.         IcEd_Xsize-=2
  2512. .        
  2513. seticontext(20,
  2514. (IcEd_Xsize),4))
  2515. (        
  2516. iconselected(IcEdW%,53) 
  2517. #          IcEd_Ysize=IcEd_Xsize
  2518. 0          
  2519. seticontext(21,
  2520. (IcEd_Ysize),4))
  2521.         
  2522.       
  2523.         
  2524.  50,52
  2525.  ;    
  2526.  (adjust% 
  2527.  (icon%=50)) 
  2528.  (select% 
  2529.  (icon%=52)) 
  2530.       
  2531.  IcEd_Ysize<998 
  2532.         IcEd_Ysize+=2
  2533. #.        
  2534. seticontext(21,
  2535. (IcEd_Ysize),4))
  2536.       
  2537. %        
  2538.       
  2539.  IcEd_Ysize>2 
  2540.         IcEd_Ysize-=2
  2541. (.        
  2542. seticontext(21,
  2543. (IcEd_Ysize),4))
  2544.       
  2545. *        
  2546. receive(buf%)
  2547.  sender%,ref%,code%,ackcode%,acktype%,fname$,ftype%,icon%,no%,boot$
  2548.  selinfo%,item%
  2549. sender%=buf%!4
  2550. ref%=buf%!8
  2551. code%=buf%!16
  2552. 4Cackcode%=0 : 
  2553.  sort of message to acknowledge this message with
  2554. 5/acktype%=17 : 
  2555.  message type of acknowledge
  2556.  sender% <> ThisTask% 
  2557.  code% 
  2558.       
  2559.  'quit' message
  2560.       
  2561. prequit
  2562.       
  2563.  data save
  2564.       
  2565.  buf%!40=&FEC 
  2566. >>        
  2567.  other app saves file to TemplEd (via Wimp$Scrap)
  2568. ?&        NewLeafName$=
  2569. str(buf%+44)
  2570. @%        $(buf%+44)="<Wimp$Scrap>"
  2571. A1        buf%!36=-1 : 
  2572.  saved file is "unsafe"
  2573.         ackcode%=2
  2574.       
  2575.       
  2576.  data save ack
  2577.       fname$=
  2578. str(buf%+44)
  2579.       
  2580.  Drag_Win% 
  2581.         
  2582.  SaveW%
  2583.           
  2584.  Exporting% 
  2585. J(            
  2586. exporttemplates(fname$)
  2587.           
  2588. L$            
  2589.  SavingSelection% 
  2590. M"              SelFname$=fname$
  2591. N+              
  2592. savetemplates(SelFname$)
  2593.             
  2594. P>              
  2595.  (buf%!36<>-1) 
  2596.  (fname$<>"<Wimp$Scrap>") 
  2597. Q)                
  2598. setmainfname(fname$)
  2599.               
  2600. S(              
  2601. savetemplates(fname$)
  2602.             
  2603.           
  2604.         
  2605.  ExportW%
  2606. W'          
  2607. export_savenames(fname$)
  2608.       
  2609. Y3      
  2610.  "OS_File",17,fname$ 
  2611.  ftype%,,,,fsize%
  2612.       
  2613.  ftype%=1 
  2614.         ackcode%=3
  2615.         buf%!36=fsize%
  2616.       
  2617. ^"      
  2618.  "Wimp_CreateMenu",,-1
  2619.       
  2620.  data load
  2621. a!      NewFname$=
  2622. str(buf%+44)
  2623.       
  2624.  buf%!40 
  2625.         
  2626.  &FEC
  2627.           
  2628.  buf%!20 
  2629.             
  2630.  TemplW%
  2631. f-              
  2632. setchanged(NrTemplates%>0)
  2633. g.              
  2634. templ_loadfile(NewFname$,0)
  2635.               ackcode%=4
  2636.             
  2637. j&              
  2638.  buf%!24=BarIcon% 
  2639. k$                
  2640.  ChangesMade% 
  2641. l%                  
  2642. dialogue(2,"")
  2643.                 
  2644. n&                  
  2645. templ_deleteall
  2646. o2                  
  2647. templ_loadfile(NewFname$,1)
  2648.                 
  2649.               
  2650.               ackcode%=4
  2651.           
  2652.         
  2653.  &FF9
  2654. u3          
  2655.  (buf%!20=-2) 
  2656.  (buf%!24=BarIcon%) 
  2657. v+            
  2658. loadusersprites(NewFname$)
  2659.             ackcode%=4
  2660.           
  2661.         
  2662.  &2000
  2663. z2          NewFname$=
  2664. str(buf%+44)+".Templates"
  2665. {H          
  2666. fileexists(NewFname$)
  2667. (buf%!20=-2)
  2668. (buf%!24=BarIcon%) 
  2669. |             
  2670.  ChangesMade% 
  2671. }!              
  2672. dialogue(2,"")
  2673.             
  2674. "              
  2675. templ_deleteall
  2676. .              
  2677. templ_loadfile(NewFname$,1)
  2678.             
  2679.             ackcode%=4
  2680.           
  2681.       
  2682. "      
  2683.  double-click on a file
  2684. !      NewFname$=
  2685. str(buf%+44)
  2686.       
  2687.  buf%!40 
  2688.         
  2689.  &FEC
  2690.            
  2691.  NrTemplates%=0 
  2692. ,            
  2693. templ_loadfile(NewFname$,1)
  2694.             ackcode%=4
  2695.           
  2696.       
  2697.       
  2698.  desktop exit
  2699.       
  2700.  ChangesMade% 
  2701.         ackcode%=8
  2702.         acktype%=19
  2703. "        PreQuitSender%=sender%
  2704.         
  2705. dialogue(8,"")
  2706.       
  2707. #      
  2708.  desktop save (RiscOS 3)
  2709. 5      boot$="Run "+
  2710. readvarval("TemplEd$Dir")+
  2711. /      
  2712.  "OS_GBPB",2,buf%!20,boot$,
  2713. (boot$)
  2714.  &502
  2715. *      
  2716.  request from !Help application
  2717. %      no%=
  2718. whichtemplate(buf%!32)
  2719.       icon%=buf%!36
  2720. $      
  2721.  (no%>=0) 
  2722.  (icon%>=-1) 
  2723. +        $(buf%+20)=
  2724. iconhelp(no%,icon%)
  2725.         ackcode%=&503
  2726.       
  2727.  &400C0
  2728. !      
  2729.  about to open submenu
  2730. =      
  2731.  "MenuUtil_Decode",LastMenu%,buf%+32 
  2732.  ,,selinfo%
  2733.       item%=selinfo%!8
  2734.       
  2735.  item% 
  2736.         
  2737.  item_createtempl%
  2738. '          
  2739.  template name to create
  2740. 3          
  2741.  "MenuUtil_Text",item_templname%,""
  2742. /        
  2743.  item_copytempl%,item_renametempl%
  2744.           
  2745. sel_get(TemplW%)
  2746. /          
  2747.  template name to copy or rename
  2748. N          
  2749.  "MenuUtil_Text",item_templname%,$(TemplNames%+28*(SelBlk%!0))
  2750.         
  2751.  item_exporttempl%
  2752. '          $(FileName%)=ExportTname$
  2753.            SavingSelection%=
  2754.           Exporting%=
  2755. '          $SaveFileIcon%="file_fff"
  2756.         
  2757.  item_exportnames%
  2758.           
  2759.  ExportType% 
  2760.             
  2761. 6              $(ExportName%)=
  2762. locase(ExportIname$)
  2763.             
  2764. -              $(ExportName%)=ExportIname$
  2765.           
  2766.         
  2767.  item_frame%
  2768.           
  2769. frame_fillwin
  2770.         
  2771.  item_save%
  2772. +          
  2773.  set filename in save window
  2774. %          $(FileName%)=MainFname$
  2775.            SavingSelection%=
  2776.           Exporting%=
  2777. '          $SaveFileIcon%="file_fec"
  2778.         
  2779.  item_savetempl%
  2780. 0          
  2781.  set template name in save window
  2782. $          $(FileName%)=SelFname$
  2783.            SavingSelection%=
  2784.           Exporting%=
  2785. '          $SaveFileIcon%="file_fec"
  2786.         
  2787.  item_workarea%
  2788. -          
  2789.  fill icons in workarea window
  2790. %          WinBlk%!0=LastMenu_Win%
  2791. .          
  2792.  "Wimp_GetWindowInfo",,WinBlk%
  2793. ,          $(IconText%(12))=
  2794. (WinBlk%!44)
  2795. ,          $(IconText%(13))=
  2796. (WinBlk%!56)
  2797. 7          $(IconText%(14))=
  2798. (WinBlk%!52-WinBlk%!44)
  2799. 7          $(IconText%(15))=
  2800. (WinBlk%!56-WinBlk%!48)
  2801. 6          $(IconText%(16))=
  2802. ((WinBlk%!72) 
  2803.  &FFFF)
  2804. 2          $(IconText%(17))=
  2805. ((WinBlk%!72)>>16)
  2806.       
  2807. :      
  2808.  "Wimp_CreateSubMenu",,buf%!20,buf%!24,buf%!28
  2809.  &400C1
  2810.       
  2811.  mode change
  2812.       
  2813. readscreenvars
  2814. =      
  2815.  TemplW_MaxCol%<TemplW_Cols% 
  2816. redefinebrowser(
  2817.  &400C9
  2818. 1      
  2819.  menu removed with no menu item chosen
  2820. "      
  2821.  LastMenu%=TemplMenu% 
  2822. :        
  2823.  TemplMenu_Deselect% 
  2824. sel_clear(TemplW%,-1)
  2825.       
  2826.  &80E1E
  2827. 4      
  2828.  OLE file (user sprites) changed - reload
  2829. (      
  2830. loadusersprites(SpriteFname$)
  2831.  ackcode%<>0 
  2832.     buf%!0=256
  2833.     buf%!12=ref%
  2834.     buf%!16=ackcode%
  2835. -    
  2836.  "Wimp_SendMessage",17,buf%,sender%
  2837. redraw(handle%)
  2838.  more%,win0x%,win0y%,dx%
  2839.  xstart%,height%,xcorr%,ycorr%,x%,y%
  2840. dx%=48
  2841. Blk%!0=handle%
  2842.  "Wimp_RedrawWindow",,Blk% 
  2843.  more%
  2844. win0x%=Blk%!4-Blk%!20
  2845. win0y%=Blk%!16-Blk%!24
  2846.  more%
  2847.  Hatch% 
  2848.     height%=Blk%!40-Blk%!32
  2849.     xstart%=Blk%!28-height%
  2850. %    xcorr%=(xstart%-win0x%) 
  2851. %    ycorr%=(win0y%-Blk%!32) 
  2852. 4    
  2853.  x%=xstart%-(xcorr%+ycorr%) 
  2854.  Blk%!36 
  2855.       
  2856.  x%,Blk%!32
  2857.       
  2858.  1,height%,height%
  2859. %    ycorr%=(win0y%-Blk%!40) 
  2860. 4    
  2861.  x%=xstart%-(xcorr%-ycorr%) 
  2862.  Blk%!36 
  2863.       
  2864.  x%,Blk%!40
  2865.       
  2866.  1,height%,-height%
  2867.  Support% 
  2868. &      
  2869.  "Wimp_BorderWindow",,Blk%
  2870. %      
  2871.  "AEH_RedrawWindow",,Blk%
  2872.     #      
  2873.  "WimpExt_Redraw",,Blk%
  2874.  "Wimp_GetRectangle",,Blk% 
  2875.  more%
  2876.  *** procs for the window-edit window ***
  2877. wined_fillwin(window%)
  2878.  no%,flags%,i%
  2879. whichtemplate(window%)
  2880. WinEd_Win%=window%
  2881. WinBlk%!0=WinEd_Win%
  2882.  "Wimp_GetWindowInfo",,WinBlk%
  2883. flags%=WinBlk%!32
  2884. "WinEd_Button%=(WinBlk%!64)>>12
  2885.  i%=0 
  2886. &  WinEd_Col%(i%)=(WinBlk%?(36+i%))
  2887. selecticon(WinEdW%,4,flags% 
  2888.  (1<<1))
  2889. selecticon(WinEdW%,5,flags% 
  2890.  (1<<4))
  2891. selecticon(WinEdW%,6,flags% 
  2892.  (1<<12))
  2893. selecticon(WinEdW%,7,PaneFlag%?no%)
  2894. selecticon(WinEdW%,8,flags% 
  2895.  (1<<6))
  2896. selecticon(WinEdW%,9,flags% 
  2897.  (1<<10))
  2898. selecticon(WinEdW%,10,flags% 
  2899.  (1<<11))
  2900. selecticon(WinEdW%,20,flags% 
  2901.  (1<<31))
  2902. selecticon(WinEdW%,57,flags% 
  2903.  (1<<13))
  2904. selecticon(WinEdW%,59,flags% 
  2905.  (1<<8))
  2906. selecticon(WinEdW%,60,flags% 
  2907.  (1<<9))
  2908. selecticon(WinEdW%,62,flags% 
  2909.  (1<<14))
  2910. selecticon(WinEdW%,63,flags% 
  2911.  (1<<15))
  2912.  i%=0 
  2913. selecticon(WinEdW%,13+i%,flags% 
  2914.  (1<<(24+i%)))
  2915.  (flags% 
  2916.  (1<<31))=0 
  2917. selecticon(WinEdW%,14,(flags% 
  2918.  (1<<7))=0)
  2919. selecticon(WinEdW%,13,(flags% 
  2920.  (1<<7))=0)
  2921. selecticon(WinEdW%,15,flags% 
  2922.  (1<<0))
  2923. selecticon(WinEdW%,17,flags% 
  2924.  (1<<2))
  2925. selecticon(WinEdW%,19,flags% 
  2926.  (1<<3))
  2927. settitlebar(WinEdW%,WinEdTbar%,
  2928. msg_lookup1("EDTP",$(TemplNames%+28*no%)))
  2929. seticontext(6,$(WinButton%+20*WinEd_Button%))
  2930.  i%=0 
  2931. setcolourbox(2+i%,WinEd_Col%(i%))
  2932. wined_shadeicons(-1)
  2933. openwindow(WinEdW%,0)
  2934. setcaret(WinEdW%,-1)
  2935. wined_shadeicons(clickedon%)
  2936.  newformat%,titlebar%,scroll%
  2937. ?(newformat%=
  2938. iconselected(WinEdW%,20)
  2939. @'titlebar%=
  2940. iconselected(WinEdW%,15)
  2941. AAscroll%=
  2942. iconselected(WinEdW%,17) 
  2943. iconselected(WinEdW%,19)
  2944.  (clickedon%=-1) 
  2945.  (clickedon%=20) 
  2946. shadeicon(WinEdW%,16,
  2947.  newformat%)
  2948.  (clickedon%=-1) 
  2949.  (clickedon%=15) 
  2950. shadeicon(WinEdW%,13,
  2951.  titlebar%)
  2952. shadeicon(WinEdW%,14,
  2953.  titlebar%)
  2954. shadeicon(WinEdW%,16,
  2955.  titlebar%)
  2956.  (clickedon%<>15) 
  2957. shadeicon(WinEdW%,18,newformat% 
  2958.  scroll%))
  2959. wined_readwin
  2960.  flags%,no%,i%
  2961. WinBlk%!0=WinEd_Win%
  2962.  "Wimp_GetWindowInfo",,WinBlk%
  2963. S!flags%=(WinBlk%!32)
  2964. (&1F<<16)
  2965. iconselected(WinEdW%,15) 
  2966.  flags%+=(1<<0)
  2967. iconselected(WinEdW%,4) 
  2968.  flags%+=(1<<1)
  2969. iconselected(WinEdW%,17) 
  2970.  flags%+=(1<<2)
  2971. iconselected(WinEdW%,19) 
  2972.  flags%+=(1<<3)
  2973. iconselected(WinEdW%,5) 
  2974.  flags%+=(1<<4)
  2975. Y"no%=
  2976. whichtemplate(WinEd_Win%)
  2977. iconselected(WinEdW%,7) 
  2978.   PaneFlag%?no%=1<<5
  2979.   PaneFlag%?no%=0
  2980. iconselected(WinEdW%,8) 
  2981.  flags%+=(1<<6)
  2982. iconselected(WinEdW%,14) 
  2983.  flags%+=(1<<7)
  2984. iconselected(WinEdW%,59) 
  2985.  flags%+=(1<<8)
  2986. iconselected(WinEdW%,60) 
  2987.  flags%+=(1<<9)
  2988. iconselected(WinEdW%,9) 
  2989.  flags%+=(1<<10)
  2990. iconselected(WinEdW%,10) 
  2991.  flags%+=(1<<11)
  2992. iconselected(WinEdW%,6) 
  2993.  flags%+=(1<<12)
  2994. iconselected(WinEdW%,57) 
  2995.  flags%+=(1<<13)
  2996. iconselected(WinEdW%,62) 
  2997.  flags%+=(1<<14)
  2998. iconselected(WinEdW%,63) 
  2999.  flags%+=(1<<15)
  3000.  i%=0 
  3001. iconselected(WinEdW%,13+i%) 
  3002.  flags%+=(1<<(24+i%))
  3003. WinBlk%!32=flags%
  3004. m WinBlk%!64=WinEd_Button%<<12
  3005.  i%=0 
  3006. o$  WinBlk%?(36+i%)=WinEd_Col%(i%)
  3007. q)WinEd_Win%=
  3008. redefinewindow(WinBlk%,1)
  3009.  *** procs for the icon-edit window ***
  3010. iced_start(window%,icon%)
  3011.  icon%=-4 
  3012. iced_fillwin(window%,-4)
  3013. sel_get(window%)
  3014.  NrSelected%>0 
  3015.      
  3016.  NrSelected%=1 
  3017. }*      
  3018. iced_fillwin(window%,SelBlk%!0)
  3019.      
  3020. $       
  3021. iced_fillwin(window%,-1)
  3022.      
  3023.  (icon%>=0) 
  3024. &      
  3025. iced_fillwin(window%,icon%)
  3026.         
  3027. iced_fillwin(window%,icon%)
  3028.  no%,flags%,data%,arg$,title$,text%,sprite%,indir%,caretto%
  3029.  t$,v$,m$,s$
  3030. IcEd_Win%=window%
  3031. IcEd_Icon%=icon%
  3032. whichtemplate(window%)
  3033. WinBlk%!0=IcEd_Win%
  3034.  "Wimp_GetWindowInfo",,WinBlk%
  3035.  icon% 
  3036.  -4  : 
  3037.  editing title bar icon
  3038. D    flags%=(WinBlk%!60) 
  3039.  &FF000FFF : 
  3040.  mask out irrelevant bits
  3041.     flags%=flags% 
  3042.  (flags% 
  3043.  (1<<6))=0 
  3044. ;      
  3045.  copy fg and bg colour flags from window colours
  3046. J      flags%=(flags% 
  3047.  &FFF) 
  3048.  ((WinBlk%?36)<<24) 
  3049.  ((WinBlk%?37)<<28)
  3050.         
  3051.     data%=WinBlk%+76
  3052. "    arg$+=
  3053. msg_lookup0("TBAR")
  3054.  -1  : 
  3055.  editing selection (read flags from first icon)
  3056. sel_get(IcEd_Win%)
  3057. -    flags%=WinBlk%!(92+32*(SelBlk%!0)+16)
  3058. *    data%=WinBlk%+92+32*(SelBlk%!0)+20
  3059. !    arg$+=
  3060. msg_lookup0("SEL")
  3061.  editing single icon
  3062. ,    flags%=WinBlk%!(92+32*IcEd_Icon%+16)
  3063. )    data%=WinBlk%+92+32*IcEd_Icon%+20
  3064. +    arg$+=
  3065. msg_lookup1("ICNR",
  3066. (icon%))
  3067. :title$=
  3068. msg_lookup2("EDIC",$(TemplNames%+28*no%),arg$)
  3069. text%=(flags% 
  3070.  1)>0
  3071. sprite%=(flags% 
  3072.  2)>0
  3073. indir%=(flags% 
  3074.  &100)>0
  3075.  text% 
  3076.  indir% 
  3077.     t$=
  3078. str(data%!0)
  3079.     m$=
  3080. (data%!8)
  3081. (    
  3082.  data%!4<>-1 
  3083. str(data%!4)
  3084.     t$=
  3085. str(data%),12)
  3086.  sprite% 
  3087.  text%) 
  3088.  indir% 
  3089.     s$=
  3090. str(data%!0)
  3091.     m$=
  3092. (data%!8)
  3093.     s$=
  3094. str(data%),12)
  3095. "IcEd_Button%=(flags%>>12) 
  3096. IcEd_Esg%=(flags%>>16) 
  3097.  (flags% 
  3098.  (1<<6)) 
  3099.   IcEd_Fgcol%=7
  3100.   IcEd_Bgcol%=0
  3101. font_getinfo((flags%>>24) 
  3102.  255,IcEd_Font$,IcEd_Xsize,IcEd_Ysize)
  3103. #  IcEd_Fgcol%=(flags%>>24) 
  3104. #  IcEd_Bgcol%=(flags%>>28) 
  3105. "  IcEd_Font$="Homerton.Medium"
  3106.   IcEd_Xsize=12
  3107.   IcEd_Ysize=12
  3108. settitlebar(IcEdW%,IcEdTbar%,title$)
  3109. selecticon(IcEdW%,12,text%)
  3110. selecticon(IcEdW%,13,sprite%)
  3111. selecticon(IcEdW%,14,indir%)
  3112. seticontext(0,t$)
  3113. seticontext(1,s$)
  3114. seticontext(2,v$)
  3115. seticontext(3,m$)
  3116. selecticon(IcEdW%,15,flags% 
  3117.  (1<<2))
  3118. selecticon(IcEdW%,17,flags% 
  3119.  (1<<3))
  3120. selecticon(IcEdW%,18,flags% 
  3121.  (1<<4))
  3122. selecticon(IcEdW%,16,flags% 
  3123.  (1<<5))
  3124. selecticon(IcEdW%,41,flags% 
  3125.  (1<<6))
  3126. selecticon(IcEdW%,20,flags% 
  3127.  (1<<7))
  3128. selecticon(IcEdW%,19,flags% 
  3129.  (1<<9))
  3130. selecticon(IcEdW%,21,flags% 
  3131.  (1<<10))
  3132. selecticon(IcEdW%,22,flags% 
  3133.  (1<<11))
  3134. selecticon(IcEdW%,39,flags% 
  3135.  (1<<22))
  3136. seticontext(4,$(IcButton%+20*IcEd_Button%))
  3137. seticontext(5,
  3138. (IcEd_Esg%))
  3139. setcolourbox(0,IcEd_Fgcol%)
  3140. setcolourbox(1,IcEd_Bgcol%)
  3141. seticontext(19,IcEd_Font$)
  3142. seticontext(20,
  3143. (IcEd_Xsize),4))
  3144. seticontext(21,
  3145. (IcEd_Ysize),4))
  3146. selecticon(IcEdW%,53,IcEd_Xsize=IcEd_Ysize)
  3147.  i%=12 
  3148. shadeicon(IcEdW%,i%,IcEd_Icon%=-1)
  3149.  IcEd_Icon%=-1 
  3150.  i%=23 
  3151. shadeicon(IcEdW%,i%,1)
  3152. shadeicon(IcEdW%,15,IcEd_Icon%=-4)
  3153. shadeicon(IcEdW%,16,IcEd_Icon%=-4)
  3154. shadeicon(IcEdW%,20,IcEd_Icon%=-4)
  3155. shadeicon(IcEdW%,21,IcEd_Icon%=-4)
  3156.  i%=27 
  3157. shadeicon(IcEdW%,i%,IcEd_Icon%=-4)
  3158. shadeicon(IcEdW%,39,IcEd_Icon%=-4)
  3159. iced_shadeicons(-1)
  3160. openwindow(IcEdW%,0)
  3161. caretto%=-1
  3162.  IcEd_Icon%<>-1 
  3163.  indir% 
  3164.  caretto%=25
  3165.  sprite% 
  3166.  caretto%=24
  3167.  text% 
  3168.  caretto%=23
  3169. setcaret(IcEdW%,caretto%)
  3170. iced_shadeicons(clickedon%)
  3171.  t%,s%,i%,f%,lockaspect%
  3172.  IcEd_Icon%<>-1 
  3173.  (clickedon%=-1) 
  3174.  (clickedon%<=14) 
  3175. #    t%=
  3176. iconselected(IcEdW%,12)
  3177. #    s%=
  3178. iconselected(IcEdW%,13)
  3179. #    i%=
  3180. iconselected(IcEdW%,14)
  3181. "    
  3182. shadeicon(IcEdW%,23,
  3183. 0    
  3184. shadeicon(IcEdW%,24,(
  3185.  s%) 
  3186.  (t% 
  3187.  i%))
  3188. (    
  3189. shadeicon(IcEdW%,25,
  3190.  i%))
  3191. "    
  3192. shadeicon(IcEdW%,26,
  3193. iconselected(IcEdW%,41)
  3194. (lockaspect%=
  3195. iconselected(IcEdW%,53)
  3196.  (clickedon%=-1) 
  3197.  (clickedon%=41) 
  3198.  i%=33 
  3199.      
  3200. shadeicon(IcEdW%,i%,f%)
  3201.  i%=45 
  3202. "    
  3203. shadeicon(IcEdW%,i%,
  3204. shadeicon(IcEdW%,53,
  3205.  (clickedon%=-1) 
  3206.  (clickedon%=41) 
  3207.  (clickedon%=53) 
  3208.  i%=50 
  3209. 2    
  3210. shadeicon(IcEdW%,i%,(
  3211.  f%) 
  3212.  lockaspect%)
  3213.  "Wimp_GetCaretPosition",,ScrapBlk%
  3214. iconshaded(ScrapBlk%!0,ScrapBlk%!4) 
  3215. setcaret(IcEdW%,-1) : 
  3216.  move caret from shaded icon
  3217. iced_readwin(mask%)
  3218.  flags%,flagptr%,data%,ib%,cbp%,xsize,ysize
  3219.  xsize16%,ysize16%,fhandle%
  3220.  i%,t%,s%,deflen%,maxlen%,p%
  3221. WinBlk%!0=IcEd_Win%
  3222.  "Wimp_GetWindowInfo",,WinBlk%
  3223.  IcEd_Icon% 
  3224.  -4  : 
  3225.  editing title bar icon
  3226.     flagptr%=WinBlk%+60
  3227.     data%=WinBlk%+76
  3228.  -1  : 
  3229.  editing selection (read flags from first icon)
  3230. sel_get(IcEd_Win%)
  3231. +-    flagptr%=WinBlk%+92+32*(SelBlk%!0)+16
  3232. ,*    data%=WinBlk%+92+32*(SelBlk%!0)+20
  3233.  editing single icon
  3234.  IcEd_Icon%>=0 
  3235. /.      flagptr%=WinBlk%+92+32*IcEd_Icon%+16
  3236. 0+      data%=WinBlk%+92+32*IcEd_Icon%+20
  3237. 1&      ib%=WinBlk%+92+32*IcEd_Icon%
  3238. 2        
  3239. cbp%=WinBlk%!68
  3240.  construct new flags, but do not change "selected" state
  3241. 6!flags%=(flagptr%!0) 
  3242.  (1<<21)
  3243. iconselected(IcEdW%,15) 
  3244.  flags%+=(1<<2)
  3245. iconselected(IcEdW%,16) 
  3246.  flags%+=(1<<5)
  3247. iconselected(IcEdW%,17) 
  3248.  flags%+=(1<<3)
  3249. iconselected(IcEdW%,18) 
  3250.  flags%+=(1<<4)
  3251. iconselected(IcEdW%,19) 
  3252.  flags%+=(1<<9)
  3253. iconselected(IcEdW%,20) 
  3254.  flags%+=(1<<7)
  3255. iconselected(IcEdW%,21) 
  3256.  flags%+=(1<<10)
  3257. iconselected(IcEdW%,22) 
  3258.  flags%+=(1<<11)
  3259. iconselected(IcEdW%,39) 
  3260.  flags%+=(1<<22)
  3261. flags%+=(IcEd_Button%<<12)
  3262. flags%+=(IcEd_Esg%<<16)
  3263. iconselected(IcEdW%,41) 
  3264.   flags%+=(1<<6)
  3265.   xsize16%=
  3266. (IcEd_Xsize*16)
  3267.   ysize16%=
  3268. (IcEd_Ysize*16)
  3269.  xsize16%<=0 
  3270.  xsize16%=12*16
  3271.  ysize16%<=0 
  3272.  ysize16%=12*16
  3273.  "Font_FindFont",,IconText%(19),xsize16%,ysize16%,0,0 
  3274.  fhandle%
  3275.  FontUsage%(fhandle%)>0 
  3276. J?    
  3277.  "Font_LoseFont",fhandle% : 
  3278.  font was already in use
  3279.   FontUsage%(fhandle%)+=1
  3280.   flags%+=(fhandle%<<24)
  3281.   flags%+=(IcEd_Fgcol%<<24)
  3282.   flags%+=(IcEd_Bgcol%<<28)
  3283.  (IcEd_Icon%>=0)
  3284. (IcEd_Icon%=-4) 
  3285. iconrelease(flagptr%!0,data%)
  3286. T!  t%=
  3287. iconselected(IcEdW%,12)
  3288. U!  s%=
  3289. iconselected(IcEdW%,13)
  3290. V!  i%=
  3291. iconselected(IcEdW%,14)
  3292.  t%) 
  3293. X=    deflen%=
  3294. ($(IconText%(1)))+1 : 
  3295.  default maximum size
  3296. Z$    deflen%=
  3297. ($(IconText%(0)))+1
  3298. ]"    maxlen%=
  3299. ($(IconText%(3)))
  3300.     maxlen%=12
  3301.  maxlen%<deflen% 
  3302. bN    maxlen%=deflen%                : 
  3303.  increase max size if text is longer
  3304. c"    
  3305. seticontext(3,
  3306. (maxlen%))
  3307.  i%) 
  3308.  (deflen%>12) 
  3309. fE    
  3310. selecticon(IcEdW%,14,1)    : 
  3311.  make indirected if > 12 chars
  3312. gA    
  3313. seticontext(2,"")          : 
  3314.  default validation string
  3315. iced_shadeicons(14)
  3316.     i%=
  3317.  flags%+=(1<<0)
  3318.  flags%+=(1<<1)
  3319.  flags%+=(1<<8)
  3320.  t%) 
  3321.       data%!0=IconText%(1)
  3322. qD      data%!4=cbp% : 
  3323.  window CBP as default sprite area pointer
  3324. r        
  3325.       data%!0=IconText%(0)
  3326. u"      
  3327. ($(IconText%(2)))>0 
  3328. v         data%!4=IconText%(2)
  3329.       
  3330. x2        data%!4=-1 : 
  3331.  empty validation string
  3332.       
  3333. z        
  3334.     data%!8=maxlen%
  3335. ~"      $(data%)=$(IconText%(0))
  3336.         
  3337.       
  3338. $        $(data%)=$(IconText%(1))
  3339.       
  3340.         
  3341.   flagptr%!0=flags%
  3342. iconrealloc(flagptr%,data%)
  3343.  IcEd_Icon% 
  3344.     WinBlk%?36=IcEd_Fgcol%
  3345.     WinBlk%?37=IcEd_Bgcol%
  3346. ,    IcEd_Win%=
  3347. redefinewindow(WinBlk%,1)
  3348. A    
  3349.  do not change text, sprite and indir flags of selection
  3350.     mask%=mask% 
  3351.  &103)
  3352.  NrSelected%>0 
  3353.        
  3354.  i%=0 
  3355.  NrSelected%-1
  3356. H        
  3357. seticonstate(IcEd_Win%,SelBlk%!(4*i%),flags% 
  3358.  mask%,mask%)
  3359.       
  3360.         
  3361.       
  3362. dialogue(9,"")
  3363.         
  3364.  IcEd_Icon%>=0 
  3365. >      IcEd_Icon%=
  3366. redefineicon(IcEd_Win%,IcEd_Icon%,ib%-8)
  3367.         
  3368.       
  3369. dialogue(4,"")
  3370.         
  3371. iconselected(IcEdW%,41) 
  3372.  font count was increased earlier when finding font handle
  3373. font_lose(fhandle%)
  3374. setchanged(
  3375.  *** menu procs ***
  3376. menu_add(text$,submenu%,genmsg%)
  3377.  handle%
  3378.  "MenuUtil_Add",,text$ 
  3379.  handle%
  3380.  submenu%<>-1 
  3381.  "MenuUtil_SubMenu",handle%,submenu%
  3382.  genmsg% 
  3383.  "MenuUtil_Warning",handle%,1
  3384. =handle%
  3385. menu_addwritable(maxlen%,validstr%)
  3386.  handle%
  3387.  "MenuUtil_Add",,"" 
  3388.  handle%
  3389.  "MenuUtil_Writable",,1,maxlen%,validstr%
  3390. =handle%
  3391.  --- shade a whole submenu, but keep it accessible ---
  3392. menu_fadesubmenu(item%,submenu%,switch%)
  3393.  switch% 
  3394.  "MenuUtil_Colours",item%,2,0
  3395.  "MenuUtil_Fade",submenu%,1
  3396.  "MenuUtil_Colours",item%,7,0
  3397.  "MenuUtil_Fade",submenu%,0
  3398. preparemenus
  3399.  "MenuUtil_Initialise",010,0
  3400.  --- custom sprites menu
  3401.  "MenuUtil_New",,"Sprites" 
  3402.  SpritesMenu%
  3403. -item_sprview%=
  3404. menu_add("View/Edit",-1,0)
  3405. -item_sprreload%=
  3406. menu_add("Re-load",-1,0)
  3407. *item_sprreset%=
  3408. menu_add("Reset",-1,0)
  3409.  --- iconbar menu
  3410.  "MenuUtil_New",,Appl$ 
  3411.  MainMenu%
  3412. )item_info%=
  3413. menu_add("Info",InfoW%,0)
  3414.  OSversion%>=300 
  3415. '  item_help%=
  3416. menu_add("Help",-1,0)
  3417.   item_help%=0
  3418. .item_options%=
  3419. menu_add("Options...",-1,0)
  3420. /item_stats%=
  3421. menu_add("Statistics...",-1,0)
  3422. Bitem_customsprites%=
  3423. menu_add("Custom sprites",SpritesMenu%,0)
  3424. %item_quit%=
  3425. menu_add("Quit",-1,0)
  3426.  --- template-name menu
  3427.  "MenuUtil_New",,"   Name:   " 
  3428.  TemplNamemenu%
  3429. +item_templname%=
  3430. menu_addwritable(12,0)
  3431.  --- template submenu
  3432.  "MenuUtil_New",,"" 
  3433.  TemplSubmenu%
  3434. 6item_copytempl%=
  3435. menu_add("Copy",TemplNamemenu%,1)
  3436. :item_renametempl%=
  3437. menu_add("Rename",TemplNamemenu%,1)
  3438. .item_deletetempl%=
  3439. menu_add("Delete",-1,0)
  3440. *item_opentempl%=
  3441. menu_add("Open",-1,0)
  3442. ,item_closetempl%=
  3443. menu_add("Close",-1,0)
  3444. .item_savetempl%=
  3445. menu_add("Save",SaveW%,1)
  3446.  --- export submenu
  3447.  "MenuUtil_New",,"Export" 
  3448.  ExportMenu%
  3449. 8item_exportnames%=
  3450. menu_add("Icon names",ExportW%,1)
  3451. 5item_exporttempl%=
  3452. menu_add("Templates",SaveW%,1)
  3453.  --- template menu
  3454.  "MenuUtil_New",,Appl$ 
  3455.  TemplMenu%
  3456. :item_createtempl%=
  3457. menu_add("Create",TemplNamemenu%,1)
  3458. 0item_template%=
  3459. menu_add("",TemplSubmenu%,0)
  3460. 2item_selalltempl%=
  3461. menu_add("Select all",-1,0)
  3462. 9item_clearseltempl%=
  3463. menu_add("Clear selection",-1,0)
  3464. 2item_export%=
  3465. menu_add("Export",ExportMenu%,1)
  3466. 0item_deleteall%=
  3467. menu_add("Delete all",-1,0)
  3468. 4item_sorttempl%=
  3469. menu_add("Sort templates",-1,0)
  3470. )item_save%=
  3471. menu_add("Save",SaveW%,1)
  3472.  --- direction menu for icon copying
  3473.  "MenuUtil_New",,"Copy" 
  3474.  DirMenu%
  3475. 'item_up%=
  3476. menu_add("Up    ^U",-1,0)
  3477. )item_down%=
  3478. menu_add("Down  ^D",-1,0)
  3479. )item_left%=
  3480. menu_add("Left  ^L",-1,0)
  3481. *item_right%=
  3482. menu_add("Right ^R",-1,0)
  3483.  --- menu for icon renumbering
  3484.  "MenuUtil_New",,"No.:" 
  3485.  IconNrmenu%
  3486. 2item_iconnr%=
  3487. menu_addwritable(4,NumValidStr%)
  3488.  --- "dimension" menu
  3489.  "MenuUtil_New",,"Dim." 
  3490.  DimensionMenu%
  3491. %item_both%=
  3492. menu_add("Both",-1,0)
  3493. "item_xdim%=
  3494. menu_add("X",-1,0)
  3495. "item_ydim%=
  3496. menu_add("Y",-1,0)
  3497.  --- user-template submenu
  3498.  "MenuUtil_New",,"" 
  3499.  UserSubmenu%
  3500. 7item_copyicon%=
  3501. menu_add("Copy      ^C",DirMenu%,0)
  3502. :item_renumbericon%=
  3503. menu_add("Renumber",IconNrmenu%,0)
  3504. 3item_deleteicon%=
  3505. menu_add("Delete    ^X",-1,0)
  3506. 1item_editicon%=
  3507. menu_add("Edit...   ^E",-1,0)
  3508.  "MenuUtil_Dots",,1
  3509. 3item_align%=
  3510. menu_add("Align     ^J",AlignW%,0)
  3511. 6item_spaceout%=
  3512. menu_add("Space out ^K",SpaceW%,0)
  3513. 3item_frame%=
  3514. menu_add("Frame     ^F",FrameW%,1)
  3515. 9item_minsize%=
  3516. menu_add("Min. size",DimensionMenu%,0)
  3517. 9item_centericon%=
  3518. menu_add("Center",DimensionMenu%,0)
  3519. :item_samesize%=
  3520. menu_add("Same size",DimensionMenu%,0)
  3521.  --- sprite area menu
  3522.  "MenuUtil_New",,"Sprites from" 
  3523.  SpriteAreaMenu% 
  3524.         .item_wimparea%=
  3525. menu_add("Wimp area",-1,0)
  3526. 2item_customarea%=
  3527. menu_add("Custom area",-1,0)
  3528.  --- submenus for tidying icons
  3529.  "MenuUtil_New",,"Ensure" 
  3530.  EnsureMenu%
  3531. 2item_tidy1%=
  3532. menu_add("Inside work area",-1,0)
  3533. 5item_tidy2%=
  3534. menu_add("Inside visible area",-1,0)
  3535.  "MenuUtil_New",,"Deleted" 
  3536.  DeletedMenu%
  3537. *item_tidy3%=
  3538. menu_add("Undelete",-1,0)
  3539. 1item_tidy4%=
  3540. menu_add("Undelete & Move",-1,0)
  3541. 'item_tidy5%=
  3542. menu_add("Purge",-1,0)
  3543.  --- "misc" submenu
  3544.  "MenuUtil_New",,"Misc" 
  3545.  MiscMenu%
  3546. 6item_centerwin%=
  3547. menu_add("Center to screen",-1,0)
  3548. ?item_spritearea%=
  3549. menu_add("Sprite area",SpriteAreaMenu%,0)
  3550. =item_ensureicons%=
  3551. menu_add("Ensure icons",EnsureMenu%,0)
  3552. @item_deletedicons%=
  3553. menu_add("Deleted icons",DeletedMenu%,0)
  3554.  --- user-template menu
  3555.  "MenuUtil_New",,"Window" 
  3556.  UserMenu%
  3557. 5item_createicon%=
  3558. menu_add("Create icon...",-1,0)
  3559. +item_icon%=
  3560. menu_add("",UserSubmenu%,0)
  3561. ;item_selallicons%=
  3562. menu_add("Select all       ^A",-1,0)
  3563. =item_clearselicons%=
  3564. menu_add("Clear selection  ^Z",-1,0)
  3565.  "MenuUtil_Dots",item_clearselicons%,1
  3566.      2item_workarea%=
  3567. menu_add("Work area",WorkW%,1)
  3568.     !:item_editwindow%=
  3569. menu_add("Edit window...   ^W",-1,0)
  3570.     "9item_edittitle%=
  3571. menu_add("Edit title...    ^T",-1,0)
  3572.     #,item_misc%=
  3573. menu_add("Misc",MiscMenu%,0)
  3574.     $8item_closewin%=
  3575. menu_add("Close window     ^Q",-1,0)
  3576.  --- menu with icon button-types
  3577.  "MenuUtil_New",,"Button type" 
  3578.  IcButtonMenu%
  3579.  i%=0 
  3580.     (/  dummy%=
  3581. menu_add($(IcButton%+20*i%),-1,0)
  3582.  --- menu with window button-types
  3583.  "MenuUtil_New",,"Button type" 
  3584.  WinButtonMenu%
  3585.  i%=0 
  3586.     -0  dummy%=
  3587. menu_add($(WinButton%+20*i%),-1,0)
  3588.  --- actual ESG menu is built when Menu is clicked
  3589. EsgMenu%=0
  3590.  --- actual colour menu is built when Menu is clicked
  3591. ColourMenu%=0
  3592.  --- font menu
  3593. fontmenu
  3594.  --- font size menu
  3595.  "MenuUtil_New",,"Size" 
  3596.  FontSizemenu%
  3597.  "MenuUtil_Add",,"10pt"
  3598.  "MenuUtil_Add",,"12pt"
  3599.  "MenuUtil_Add",,"16pt"
  3600.  "MenuUtil_Add",,"20pt"
  3601.  "MenuUtil_Add",,"24pt"
  3602.  "MenuUtil_Add",,"36pt"
  3603.     =6item_fontsize%=
  3604. menu_addwritable(5,FpNumValidStr%)
  3605.  --- "partial update" submenu
  3606.  "MenuUtil_New",,"Other" 
  3607.  UpdateSubmenu%
  3608.     @(item_updbo%=
  3609. menu_add("Border",-1,0)
  3610.     A(item_updfi%=
  3611. menu_add("Filled",-1,0)
  3612.     B*item_updhc%=
  3613. menu_add("H centre",-1,0)
  3614.     C*item_updvc%=
  3615. menu_add("V centre",-1,0)
  3616.     D-item_updrj%=
  3617. menu_add("R justified",-1,0)
  3618.     E,item_updnh%=
  3619. menu_add("Needs help",-1,0)
  3620.     F.item_updaa%=
  3621. menu_add("Allow adjust",-1,0)
  3622.     G+item_updhs%=
  3623. menu_add("Half size",-1,0)
  3624.     H(item_updsh%=
  3625. menu_add("Shaded",-1,0)
  3626.  --- "partial update" menu
  3627.  "MenuUtil_New",,"Update" 
  3628.  Updatemenu%
  3629.     K-item_updbt%=
  3630. menu_add("Button type",-1,0)
  3631.     L&item_updesg%=
  3632. menu_add("ESG",-1,0)
  3633.     M(item_updfg%=
  3634. menu_add("Fg col",-1,0)
  3635.     N(item_updbg%=
  3636. menu_add("Bg col",-1,0)
  3637.     O(item_updfont%=
  3638. menu_add("Font",-1,0)
  3639.     P;item_updrest%=
  3640. menu_add("Other flags",UpdateSubmenu%,0)
  3641. mainmenu
  3642.  "MenuUtil_Fade",item_stats%,NrTemplates%=0
  3643. menu_fadesubmenu(item_customsprites%,SpritesMenu%,UserSprites%=1)
  3644. templatemenu(
  3645.  xpos%,
  3646.  ypos%,icon%)
  3647. sel_get(TemplW%)
  3648.  (NrSelected%=0) 
  3649.  (icon%>=0) 
  3650.     \"  
  3651. selecticon(TemplW%,icon%,1)
  3652.   SelBlk%!0=icon%
  3653.   NrSelected%=1
  3654.     _D  TemplMenu_Deselect%=
  3655.  deselect icon when menu is removed?
  3656.   TemplMenu_Deselect%=
  3657. menu_fadesubmenu(item_template%,TemplSubmenu%,NrSelected%=0)
  3658.     d    t$=""
  3659.  NrSelected%>1 
  3660.   t$="Selection"
  3661.     g)  
  3662.  "MenuUtil_Text",TemplSubmenu%,t$
  3663.  NrSelected%=1 
  3664.     j(    t$=$(TemplNames%+28*(SelBlk%!0))
  3665.     l1  
  3666.  "MenuUtil_Text",TemplSubmenu%,"Template"
  3667.  "MenuUtil_Fade",item_copytempl%,NrSelected%<>1
  3668.  "MenuUtil_Fade",item_renametempl%,NrSelected%<>1
  3669. SelFname$=t$
  3670.  NrSelected%>1 
  3671.     r3  
  3672.  "MenuUtil_Text",item_template%,"Selection"
  3673.     t;  
  3674.  "MenuUtil_Text",item_template%,"Template '"+t$+"'"
  3675.  "MenuUtil_Fade",item_selalltempl%,NrTemplates%=0
  3676.  "MenuUtil_Fade",item_clearseltempl%,NrSelected%=0
  3677.  "MenuUtil_Fade",item_deleteall%,NrTemplates%=0
  3678.  "MenuUtil_Fade",item_sorttempl%,NrTemplates%=0
  3679. menu_fadesubmenu(item_export%,ExportMenu%,NrTemplates%=0)
  3680.  "MenuUtil_Fade",item_save%,NrTemplates%=0
  3681. QuitAfterSave%=
  3682. xpos%-=64
  3683.  NrSelected%=0 
  3684.   ypos%+=22
  3685.   ypos%+=66
  3686. usermenu(
  3687.  xpos%,
  3688.  ypos%,window%,icon%)
  3689.  t$,st$
  3690. sel_get(window%)
  3691.  (NrSelected%=0) 
  3692.  (icon%>=0) 
  3693.   SelBlk%!0=icon%
  3694.   NrSelected%=1
  3695. menu_fadesubmenu(item_icon%,UserSubmenu%,NrSelected%=0)
  3696.  NrSelected% 
  3697.     t$="No icon"
  3698.     st$=t$
  3699.      t$="Icon #"+
  3700. (SelBlk%!0)
  3701.     st$=t$
  3702.     t$="Selection"
  3703. #    st$=
  3704. (NrSelected%)+" icons"
  3705.  "MenuUtil_Text",UserSubmenu%,st$
  3706.  "MenuUtil_Fade",item_renumbericon%,NrSelected%=0
  3707.  "MenuUtil_Fade",item_align%,NrSelected%<2
  3708.  "MenuUtil_Fade",item_spaceout%,NrSelected%<2
  3709.  "MenuUtil_Fade",item_frame%,NrSelected%<2
  3710.  "MenuUtil_Text",item_iconnr%,
  3711. (NextIconNr%)
  3712.  "MenuUtil_Fade",item_samesize%,NrSelected%<2
  3713. WinBlk%!0=window%
  3714.  "Wimp_GetWindowInfo",,WinBlk%
  3715.  WinBlk%!68=1 
  3716.  "MenuUtil_TickOnly",SpriteAreaMenu%,0
  3717.  "MenuUtil_TickOnly",SpriteAreaMenu%,1
  3718.  "MenuUtil_Text",item_icon%,t$
  3719.  "MenuUtil_Fade",item_selallicons%,WinBlk%!88=0
  3720.  "MenuUtil_Fade",item_clearselicons%,NrSelected%=0
  3721. menu_fadesubmenu(item_ensureicons%,EnsureMenu%,WinBlk%!88=0)
  3722.  "Wimp_WhichIcon",window%,SelBlk2%,1<<23,1<<23 : 
  3723.  any deleted icons?
  3724. menu_fadesubmenu(item_deletedicons%,DeletedMenu%,SelBlk2%!0=-1)
  3725. menu_fadesubmenu(item_spritearea%,SpriteAreaMenu%,UserSprites%=1)
  3726. xpos%-=64
  3727.  NrSelected%=0 
  3728.   ypos%+=22
  3729.   ypos%+=66
  3730. icbuttonmenu(
  3731.  xpos%,
  3732.  ypos%)
  3733.  "MenuUtil_TickOnly",IcButtonMenu%,IcEd_Button%
  3734. xpos%+=16
  3735. ypos%+=22+IcEd_Button%*44
  3736. winbuttonmenu(
  3737.  xpos%,
  3738.  ypos%)
  3739.  "MenuUtil_TickOnly",WinButtonMenu%,WinEd_Button%
  3740. xpos%+=16
  3741. ypos%+=22+WinEd_Button%*44
  3742. esgmenu(
  3743.  xpos%,
  3744.  ypos%)
  3745.  EsgMenu%<>0 
  3746.  "MenuUtil_Delete",EsgMenu%,
  3747.  Support%=2 
  3748.  "MenuUtil_New",,"ESG" 
  3749.  EsgMenu%
  3750. .  dummy%=
  3751. menu_addwritable(3,NumValidStr%)
  3752.  "MenuUtil_Text",,
  3753. (IcEd_Esg%)
  3754. *  dummy%=
  3755. menu_add("16 (Action)",-1,0)
  3756. 2  dummy%=
  3757. menu_add("18 (Default action)",-1,0)
  3758. ,  dummy%=
  3759. menu_add("19 (Writable)",-1,0)
  3760. +  dummy%=
  3761. menu_add("20 (Display)",-1,0)
  3762. -  dummy%=
  3763. menu_add("21 (Group box)",-1,0)
  3764. 0  dummy%=
  3765. menu_add("24 (24bit colour)",-1,0)
  3766. *  dummy%=
  3767. menu_add("25 (Slider)",-1,0)
  3768.   ypos%+=22
  3769.  "MenuUtil_New",,"ESG" 
  3770.  EsgMenu%
  3771.  i%=0 
  3772. $    dummy%=
  3773. menu_add(
  3774. (i%),-1,0)
  3775.   ypos%+=22
  3776.  IcEd_Esg%<=15 
  3777. 1    
  3778.  "MenuUtil_TickOnly",EsgMenu%,IcEd_Esg%
  3779.     ypos%+=IcEd_Esg%*44
  3780. xpos%+=16
  3781. colourmenu(
  3782.  xpos%,
  3783.  ypos%,window%,icon%)
  3784.  i%,flags%,current%,bigrange%,transp%
  3785.  ColourMenu%<>0 
  3786.  "MenuUtil_Delete",ColourMenu%,
  3787.  window% 
  3788.  IcEdW%
  3789.  icon% 
  3790. %      
  3791.  34 : current%=IcEd_Fgcol%
  3792. %      
  3793.  37 : current%=IcEd_Bgcol%
  3794.         
  3795.     bigrange%=
  3796.     transp%=
  3797.  WinEdW%
  3798. *    bigrange%=
  3799. iconselected(WinEdW%,9)
  3800. %    transp%=(icon%=27)
  3801. (icon%=39)
  3802. )    current%=WinEd_Col%((icon%-27)
  3803.  bigrange% 
  3804.  colour menu for colour numbers 0-255 (GCOL colours)
  3805.  "MenuUtil_New",,"Col" 
  3806.  ColourMenu%
  3807. .  dummy%=
  3808. menu_addwritable(4,NumValidStr%)
  3809.  "MenuUtil_Text",,
  3810. (current%)
  3811.  transp% 
  3812. !    
  3813.  "MenuUtil_Add",,"None"
  3814. (    
  3815.  "MenuUtil_Tick",,current%=255
  3816.  colour menu for colour numbers 0-15
  3817.  "MenuUtil_New",,"Col" 
  3818.  ColourMenu%
  3819.  i%=0 
  3820.      
  3821.  "MenuUtil_Add",,
  3822. 4    
  3823.  "MenuUtil_Colours",,InverseColour%(i%),i%
  3824.  transp% 
  3825.  "MenuUtil_Dots",,1
  3826. !    
  3827.  "MenuUtil_Add",,"None"
  3828.  current%=255 
  3829. -    
  3830.  "MenuUtil_TickOnly",ColourMenu%,16
  3831. 3    
  3832.  "MenuUtil_TickOnly",ColourMenu%,current%
  3833. xpos%+=16
  3834. ypos%+=22
  3835.  bigrange%) 
  3836.  current%=255 
  3837.     ypos%+=16*44+22
  3838.     ypos%+=current%*44
  3839. fontmenu
  3840.  next%,font$,fam$,style$,p%,submenu%,item%
  3841.  "MenuUtil_New",,"Font" 
  3842.  FontMenu%
  3843. fam$=""
  3844. next%=0
  3845.   f$=
  3846. 40," ")
  3847.  "Font_ListFonts",,FontData%,next%,-1 
  3848.  ,,next%
  3849.  next%<>-1 
  3850.     f$=$(FontData%)
  3851.     p%=
  3852. f$,".")
  3853.  p%>0 
  3854.       style$=
  3855. f$,p%+1)
  3856.       f$=
  3857. f$,p%-1)
  3858.          
  3859.       style$="(Regular)"
  3860. "        
  3861. #$    
  3862.  (f$<>fam$) 
  3863.  (next%<>-1) 
  3864.       
  3865.  new font family
  3866.       fam$=f$
  3867. &2      
  3868.  "MenuUtil_Add",FontMenu%,fam$ 
  3869.  item%
  3870. ',      
  3871.  "MenuUtil_New",,fam$ 
  3872.  submenu%
  3873. (.      
  3874.  "MenuUtil_SubMenu",item%,submenu%
  3875. )        
  3876. *)    
  3877.  "MenuUtil_Add",submenu%,style$
  3878.  next%=-1
  3879. fontsizemenu(
  3880.  xpos%,
  3881.  ypos%,window%,icon%)
  3882.  icon%=48 
  3883.  "MenuUtil_Text",item_fontsize%,
  3884. (IcEd_Xsize),5)
  3885.  "MenuUtil_Text",item_fontsize%,
  3886. (IcEd_Ysize),5)
  3887. ypos%+=7*44
  3888. updatemenu(
  3889.  xpos%,
  3890.  ypos%,window%,icon%)
  3891.  font%
  3892. :"font%=
  3893. iconselected(IcEdW%,41)
  3894.  "MenuUtil_Fade",item_updfg%,font%
  3895.  "MenuUtil_Fade",item_updbg%,font%
  3896.  "MenuUtil_Fade",item_updfont%,
  3897.  font%
  3898. ypos%+=22
  3899. createmenu(xpos%,ypos%,window%,icon%)
  3900. LastMenu_X%=xpos%
  3901. LastMenu_Y%=ypos%
  3902. LastMenu_Win%=window%
  3903. LastMenu_Icon%=icon%
  3904. LastMenu%=-1
  3905.  window% 
  3906. mainmenu
  3907.     LastMenu%=MainMenu%
  3908.  TemplW%
  3909. L(    
  3910. templatemenu(xpos%,ypos%,icon%)
  3911.     LastMenu%=TemplMenu%
  3912.  IcEdW%
  3913.  icon% 
  3914.       
  3915.  9,10
  3916.         
  3917.  IcEd_Icon%=-1 
  3918. R4          
  3919. updatemenu(xpos%,ypos%,window%,icon%)
  3920. S#          LastMenu%=Updatemenu%
  3921.         
  3922.       
  3923. V&        
  3924. icbuttonmenu(xpos%,ypos%)
  3925. W#        LastMenu%=IcButtonMenu%
  3926.       
  3927. Y!        
  3928. esgmenu(xpos%,ypos%)
  3929.         LastMenu%=EsgMenu%
  3930.       
  3931.  34,37
  3932. \2        
  3933. colourmenu(xpos%,ypos%,window%,icon%)
  3934. ]!        LastMenu%=ColourMenu%
  3935.       
  3936.  45,46
  3937.         xpos%+=16
  3938.         ypos%+=22
  3939.         LastMenu%=FontMenu%
  3940.       
  3941.  48,51
  3942. c4        
  3943. fontsizemenu(xpos%,ypos%,window%,icon%)
  3944. d#        LastMenu%=FontSizemenu%
  3945. e        
  3946.  WinEdW%
  3947.  icon% 
  3948.       
  3949. i'        
  3950. winbuttonmenu(xpos%,ypos%)
  3951. j$        LastMenu%=WinButtonMenu%
  3952. k       
  3953.  27,31,35,39,43,47,51
  3954. l2        
  3955. colourmenu(xpos%,ypos%,window%,icon%)
  3956. m!        LastMenu%=ColourMenu%
  3957. n        
  3958. p&    
  3959. whichtemplate(window%)>=0 
  3960. q.      
  3961. usermenu(xpos%,ypos%,window%,icon%)
  3962.       LastMenu%=UserMenu%
  3963. s        
  3964.  LastMenu%<>-1 
  3965.   ScrapBlk%!0=xpos%
  3966.   ScrapBlk%!4=ypos%
  3967.   ScrapBlk%!12=window%
  3968.  "MenuUtil_Show",LastMenu%,ScrapBlk%
  3969.  create a window-menu
  3970. createwinmenu(window%,menuwin%,xofs%,yofs%)
  3971.  "Wimp_GetPointerInfo",,PtrInfo%
  3972.  "Wimp_CreateMenu",,menuwin%,PtrInfo%!0+xofs%,PtrInfo%!4+yofs%
  3973. LastMenu_Win%=window%
  3974. LastMenu_Icon%=-1
  3975.  *** drag procs; for moving and resizing icons ***
  3976. finishdrag(xmin%,ymin%,xmax%,ymax%)
  3977.  win0x%,win0y%,i%,iconblk%,inbox%
  3978. setmouseshape(0)                  : 
  3979.  restore default pointer shape
  3980.  xmin%>xmax% 
  3981.  xmin%,xmax%
  3982.  ymin%>ymax% 
  3983.  ymin%,ymax%
  3984.  "Wimp_GetPointerInfo",,PtrInfo%
  3985.  Drag_Type% 
  3986.  0,1 : 
  3987.  move / resize icon(s)
  3988. *    
  3989. whichtemplate(PtrInfo%!12)>=0 
  3990.       WinBlk%!0=PtrInfo%!12
  3991. *      
  3992.  "Wimp_GetWindowInfo",,WinBlk%
  3993. %      win0x%=WinBlk%!4-WinBlk%!20
  3994. &      win0y%=WinBlk%!16-WinBlk%!24
  3995. I      xmin%-=win0x% : 
  3996.  translate from screen coords to window coords
  3997.       ymin%-=win0y%
  3998.       xmax%-=win0x%
  3999.       ymax%-=win0y%
  4000. O      
  4001. moveresize(Drag_Win%,Drag_Icon%,PtrInfo%!12,xmin%,ymin%,xmax%,ymax%)
  4002. A      
  4003. setcaret(PtrInfo%!12,-1) : 
  4004.  move focus to this window
  4005.         
  4006. -      
  4007.  DeleteOutside% 
  4008.  (Drag_Type%=0) 
  4009. D        
  4010.  moved icons outside window - delete them if option set
  4011. "        
  4012.  i%=0 
  4013.  NrSelected%-1
  4014. 7          
  4015. deleteicon(Drag_Win%,SelBlk%!(4*i%),1,1)
  4016.         
  4017.       
  4018.         
  4019.  2,3 : 
  4020.  drag-select icons (with Select/Adjust)
  4021.     WinBlk%!0=Drag_Win%
  4022. (    
  4023.  "Wimp_GetWindowInfo",,WinBlk%
  4024. #    win0x%=WinBlk%!4-WinBlk%!20
  4025. $    win0y%=WinBlk%!16-WinBlk%!24
  4026.     xmin%-=win0x%
  4027.     xmax%-=win0x%
  4028.     ymin%-=win0y%
  4029.     ymax%-=win0y%
  4030. >    
  4031.  (WinBlk%!88>0) 
  4032.  ((xmax%-xmin%)+(ymax%-ymin%)>=32) 
  4033.       
  4034.  i%=0 
  4035.  WinBlk%!88-1
  4036. %        iconblk%=WinBlk%+92+i%*32
  4037. ;        inbox%=(iconblk%!0<xmax%) 
  4038.  (iconblk%!8>=xmin%)
  4039. E        inbox%=inbox% 
  4040.  (iconblk%!4<ymax%) 
  4041.  (iconblk%!12>=ymin%)
  4042. )        
  4043.  inbox% 
  4044.  (i%<>Drag_Icon%) 
  4045.           
  4046.  Drag_Type%=2 
  4047. +            
  4048. selecticon(Drag_Win%,i%,1)
  4049.           
  4050. 3            
  4051. seticonstate(Drag_Win%,i%,1<<21,0)
  4052.           
  4053.         
  4054.       
  4055.         
  4056.  4 : 
  4057.  drag from save-box
  4058. .    
  4059.  DragASprite% 
  4060.  "DragASprite_Stop"
  4061.     Blk%!0=256
  4062.     Blk%!12=0
  4063.     Blk%!16=1
  4064.     Blk%!20=PtrInfo%!12
  4065.     Blk%!24=PtrInfo%!16
  4066.     Blk%!28=PtrInfo%!0
  4067.     Blk%!32=PtrInfo%!4
  4068.  Drag_Win% 
  4069.       
  4070.  SaveW%
  4071.         
  4072.  Exporting% 
  4073.           Blk%!36=1
  4074.           Blk%!40=&FFF
  4075.         
  4076. G          Blk%!36=20+112*NrTemplates% : 
  4077.  low estimate of file size
  4078.           Blk%!40=&FEC
  4079.         
  4080. .        $(Blk%+44)=
  4081. leafname($(FileName%))
  4082.       
  4083.  ExportW%
  4084.         Blk%!36=1
  4085.         
  4086.  ExportType% 
  4087.            
  4088.  0 : Blk%!40=&FFB
  4089. "          
  4090.  1,2 : Blk%!40=&FFF
  4091.         
  4092. 0        $(Blk%+44)=
  4093. leafname($(ExportName%))
  4094.         
  4095. =    
  4096.  "Wimp_SendMessage",17,Blk%,PtrInfo%!12,PtrInfo%!16
  4097.  5,6,7
  4098. L    
  4099.  window move/resize/workresize - do nothing (no drag event anyway!)
  4100. Drag_Type%=-1
  4101. initdrag(type%,window%,icon%,box0x%,box0y%)
  4102.  "OS_Byte",161,&1C 
  4103.  ,,b% : 
  4104.  read "dragasprite" bit in CMOS RAM (RO3)
  4105. DragASprite%=(b% 
  4106.  2)<>0
  4107.  DragASprite% 
  4108.  (type%=4) 
  4109.   ScrapBlk%!0=window%
  4110.   ScrapBlk%!4=2
  4111.  "Wimp_GetIconState",,ScrapBlk%
  4112.  "DragASprite_Start",&A1,1,ScrapBlk%!28,DragBlk%+8,DragBlk%+24
  4113.  "Wimp_DragBox",1,DragBlk%
  4114. =Drag_Type%=type%   : 
  4115.  is not the same as Wimp drag type!
  4116. Drag_Win%=window%
  4117. Drag_Icon%=icon%
  4118. DDrag_Box0x%=box0x% : 
  4119.  window coords of bottomleft corner of box
  4120. Drag_Box0y%=box0y%
  4121. ,Drag_BoxSizex%=
  4122. (DragBlk%!16-DragBlk%!8)
  4123. -Drag_BoxSizey%=
  4124. (DragBlk%!20-DragBlk%!12)
  4125.  "Wimp_GetPointerInfo",,PtrInfo%
  4126. Drag_Ptrx%=PtrInfo%!0
  4127. Drag_Ptry%=PtrInfo%!4
  4128. abortdrag
  4129.  DragASprite% 
  4130.  (Drag_Type%=4) 
  4131.  "DragASprite_Stop"
  4132.  "Wimp_DragBox",,-1
  4133. setmouseshape(0)          : 
  4134.  restore default pointer shape
  4135.  Drag_Type%=7 
  4136.  restore work area size
  4137.   WinBlk%!0=Drag_Win%
  4138.  "Wimp_GetWindowState",,WinBlk%
  4139.   WinBlk%!52=Drag_WAmaxX%
  4140.   WinBlk%!48=Drag_WAminY%
  4141. *  Drag_Win%=
  4142. redefinewindow(WinBlk%,
  4143. Drag_Type%=-1
  4144. startwindowmove(window%)
  4145. DragBlk%!0=window%
  4146. DragBlk%!4=1
  4147. initdrag(5,-1,-1,0,0)
  4148. startwindowresize(window%)
  4149. DragBlk%!0=window%
  4150. DragBlk%!4=2
  4151. initdrag(6,-1,-1,0,0)
  4152. startworkarearesize(window%)
  4153. WinBlk%!0=window%
  4154.  "Wimp_GetWindowInfo",,WinBlk%
  4155. LDrag_WAmaxX%=WinBlk%!52 : 
  4156.  save, so it can be restored when drag aborts
  4157. Drag_WAminY%=WinBlk%!48
  4158. BWinBlk%!52=2000  : 
  4159.  temporarily make work area very large, so
  4160. NWinBlk%!48=-2000 : 
  4161.  window-resize drag that follows is not confined by it
  4162. &window%=
  4163. redefinewindow(WinBlk%,
  4164. setcaret(window%,-1)
  4165. DragBlk%!0=window%
  4166. DragBlk%!4=2
  4167. initdrag(7,window%,-1,0,0)
  4168. starticondrag(button%,window%,icon%)
  4169.  button% 
  4170.  1,256
  4171. sel_get(window%)
  4172.  NrSelected%>0 
  4173. $&      
  4174. starticonresize(window%,-1)
  4175. %        
  4176. &6      
  4177.  icon%>=0 
  4178. starticonresize(window%,icon%)
  4179. '        
  4180.  4,1024
  4181. sel_get(window%)
  4182.  NrSelected%>0 
  4183. +$      
  4184. starticonmove(window%,-1)
  4185. ,        
  4186. -4      
  4187.  icon%>=0 
  4188. starticonmove(window%,icon%)
  4189. .        
  4190. starticonmove(window%,icon%)
  4191.  win0x%,win0y%,xmin%,xmax%,ymin%,ymax%
  4192. WinBlk%!0=window%
  4193.  "Wimp_GetWindowState",,WinBlk%
  4194. win0x%=WinBlk%!4-WinBlk%!20
  4195. 7 win0y%=WinBlk%!16-WinBlk%!24
  4196.  icon%>=0 
  4197. 96  SelBlk%!0=icon% : 
  4198.  simulate selection of 1 icon
  4199.   NrSelected%=1
  4200. sel_get(window%)
  4201. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  4202.  "Wimp_GetPointerInfo",,PtrInfo%
  4203. DragBlk%!4=5
  4204. DragBlk%!8=xmin%+win0x%
  4205. DragBlk%!12=ymin%+win0y%
  4206. DragBlk%!16=xmax%+win0x%
  4207. DragBlk%!20=ymax%+win0y%
  4208. E%DragBlk%!24=DragBlk%!8-PtrInfo%!0
  4209. F&DragBlk%!28=DragBlk%!12-PtrInfo%!4
  4210. G4DragBlk%!32=ScreenSize_X%+DragBlk%!16-PtrInfo%!0
  4211. H4DragBlk%!36=ScreenSize_Y%+DragBlk%!20-PtrInfo%!4
  4212. initdrag(0,window%,icon%,xmin%,ymin%)
  4213. setmouseshape(1)
  4214. starticonresize(window%,icon%)
  4215.  ibxmin%,ibxmax%,ibymin%,ibymax%
  4216.  pbxmin%,pbxmax%,pbymin%,pbymax%
  4217.  a,b,c
  4218.  ibsizex%,ibsizey%,minsizex%,minsizey%
  4219.  shape%
  4220.  win0x%,win0y%,xmin%,xmax%,ymin%,ymax%
  4221. WinBlk%!0=window%
  4222.  "Wimp_GetWindowState",,WinBlk%
  4223. win0x%=WinBlk%!4-WinBlk%!20
  4224. W win0y%=WinBlk%!16-WinBlk%!24
  4225.  icon%>=0 
  4226. Y6  SelBlk%!0=icon% : 
  4227.  simulate selection of 1 icon
  4228.   NrSelected%=1
  4229. sel_get(window%)
  4230. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  4231. _Fibxmin%=win0x%+xmin% : 
  4232.  for initial box, convert to screen coords
  4233. ibymin%=win0y%+ymin%
  4234. ibxmax%=win0x%+xmax%
  4235. ibymax%=win0y%+ymax%
  4236. ibsizex%=xmax%-xmin%
  4237. ibsizey%=ymax%-ymin%
  4238.  at first, set parent box equal to initial box
  4239. pbxmin%=ibxmin%
  4240. pbymin%=ibymin%
  4241. pbxmax%=ibxmax%
  4242. pbymax%=ibymax%
  4243.  fixed minimum size of drag box (very difficult to calculate!)
  4244. minsizex%=4
  4245. minsizey%=4
  4246.  minsizex%>ibsizex% 
  4247.  minsizex%=ibsizex%
  4248.  minsizey%>ibsizey% 
  4249.  minsizey%=ibsizey%
  4250.  get position of window on screen
  4251. WinBlk%!0=window%
  4252.  "Wimp_GetWindowState",,WinBlk%
  4253.  determine which side to drag - test mouse position relative to
  4254.  diagonals of box
  4255.  diagonal 1 (bottomleft-topright) y = a*x + b
  4256.  diagonal 2 (topleft-bottomright) y = -a*x + c
  4257. a=ibsizey%/ibsizex%
  4258. b=ibymin%-a*ibxmin%
  4259. c=ibymax%+a*ibxmin%
  4260.  "Wimp_GetPointerInfo",,PtrInfo%
  4261.  PtrInfo%!4>(a*(PtrInfo%!0)+b) 
  4262.  above diagonal 1
  4263.  PtrInfo%!4>(-a*(PtrInfo%!0)+c) 
  4264. }*    
  4265.  above diagonal 2 - drag top side
  4266. ~:    
  4267.  WinBlk%!16>ibymax% 
  4268.  pbymax%=WinBlk%!16-ibsizey%
  4269.     pbymin%+=minsizey%
  4270.     shape%=2
  4271. ?    
  4272.  ibymin%,ibymax% : 
  4273.  top side of box must be "rubber"
  4274. +    
  4275.  below diagonal 2 - drag left side
  4276. 8    
  4277.  WinBlk%!4<ibxmin% 
  4278.  pbxmin%=WinBlk%!4+ibsizex%
  4279.     pbxmax%-=minsizex%
  4280.     shape%=5
  4281. @    
  4282.  ibxmin%,ibxmax% : 
  4283.  left side of box must be "rubber"
  4284.  below diagonal 1
  4285.  PtrInfo%!4>(-a*(PtrInfo%!0)+c) 
  4286. ,    
  4287.  above diagonal 2 - drag right side
  4288. 1    
  4289.  pbxmax%<WinBlk%!12 
  4290.  pbxmax%=WinBlk%!12
  4291. #    pbxmin%-=ibsizex%-minsizex%
  4292.     shape%=3
  4293. -    
  4294.  below diagonal 2 - drag bottom side
  4295. /    
  4296.  pbymin%>WinBlk%!8 
  4297.  pbymin%=WinBlk%!8
  4298. #    pbymax%+=ibsizey%-minsizey%
  4299.     shape%=4
  4300. DragBlk%!4=6
  4301. DragBlk%!8=ibxmin%
  4302. DragBlk%!12=ibymin%
  4303. DragBlk%!16=ibxmax%
  4304. DragBlk%!20=ibymax%
  4305. DragBlk%!24=pbxmin%
  4306. DragBlk%!28=pbymin%
  4307. DragBlk%!32=pbxmax%
  4308. DragBlk%!36=pbymax%
  4309. initdrag(1,window%,icon%,xmin%,ymin%)
  4310. setmouseshape(shape%)
  4311. dragselect(button%)
  4312.  Drag_Type%<0 
  4313.  "Wimp_GetPointerInfo",,PtrInfo%
  4314.   DragBlk%!4=6
  4315.   DragBlk%!8=PtrInfo%!0
  4316.   DragBlk%!12=PtrInfo%!4
  4317.   DragBlk%!16=PtrInfo%!0
  4318.   DragBlk%!20=PtrInfo%!4
  4319.   WinBlk%!0=PtrInfo%!12
  4320.  "Wimp_GetWindowState",,WinBlk%
  4321.   DragBlk%!24=WinBlk%!4
  4322.   DragBlk%!28=WinBlk%!8
  4323.   DragBlk%!32=WinBlk%!12
  4324.   DragBlk%!36=WinBlk%!16
  4325.  button%=1 
  4326. E    
  4327. initdrag(3,PtrInfo%!12,PtrInfo%!16,0,0) : 
  4328.  drag with Adjust
  4329. E    
  4330. initdrag(2,PtrInfo%!12,PtrInfo%!16,0,0) : 
  4331.  drag with Select
  4332. startsavedrag(window%)
  4333.  win0x%,win0y%
  4334. WinBlk%!0=window%
  4335.  "Wimp_GetWindowState",,WinBlk%
  4336. win0x%=WinBlk%!4-WinBlk%!20
  4337.  win0y%=WinBlk%!16-WinBlk%!24
  4338. ScrapBlk%!0=window%
  4339. ScrapBlk%!4=2
  4340.  "Wimp_GetIconState",,ScrapBlk%
  4341. DragBlk%!4=5
  4342. !DragBlk%!8=ScrapBlk%!8+win0x%
  4343. #DragBlk%!12=ScrapBlk%!12+win0y%
  4344. #DragBlk%!16=ScrapBlk%!16+win0x%
  4345. #DragBlk%!20=ScrapBlk%!20+win0y%
  4346.  "Wimp_GetPointerInfo",,PtrInfo%
  4347. %DragBlk%!24=DragBlk%!8-PtrInfo%!0
  4348. &DragBlk%!28=DragBlk%!12-PtrInfo%!4
  4349. 4DragBlk%!32=ScreenSize_X%+DragBlk%!16-PtrInfo%!0
  4350. 4DragBlk%!36=ScreenSize_Y%+DragBlk%!20-PtrInfo%!4
  4351. initdrag(4,window%,2,0,0)
  4352.  --- move or resize icons, based on new coords of box ---
  4353. moveresize(oldwin%,icon%,newwin%,xmin%,ymin%,xmax%,ymax%)
  4354.  oldxmin%,oldymin%,oldxmax%,oldymax%
  4355.  xscale,yscale,new%,i%
  4356.  icon%>=0 
  4357. 6  SelBlk%!0=icon% : 
  4358.  simulate selection of 1 icon
  4359.   NrSelected%=1
  4360. sel_get(oldwin%)
  4361.  NrSelected%>0 
  4362. sel_box(oldwin%,oldxmin%,oldymin%,oldxmax%,oldymax%)
  4363.  calculate scaling factors (will be 1 for move)
  4364. .  xscale=(xmax%-xmin%)/(oldxmax%-oldxmin%)
  4365. .  yscale=(ymax%-ymin%)/(oldymax%-oldymin%)
  4366.  i%=0 
  4367.  NrSelected%-1
  4368.     IconBlk%!0=oldwin%
  4369. !    IconBlk%!4=SelBlk%!(4*i%)
  4370. (    
  4371.  "Wimp_GetIconState",,IconBlk%
  4372. <    IconBlk%!8=xmin%+
  4373. ((IconBlk%!8-oldxmin%)*xscale+0.5)
  4374. >    IconBlk%!12=ymin%+
  4375. ((IconBlk%!12-oldymin%)*yscale+0.5)
  4376. >    IconBlk%!16=xmin%+
  4377. ((IconBlk%!16-oldxmin%)*xscale+0.5)
  4378. >    IconBlk%!20=ymin%+
  4379. ((IconBlk%!20-oldymin%)*yscale+0.5)
  4380.  oldwin%=newwin% 
  4381. (      
  4382.  move / resize in same window
  4383. =      new%=
  4384. redefineicon(oldwin%,SelBlk%!(4*i%),IconBlk%)
  4385.         
  4386. 3      
  4387.  move to other other window = copy icons
  4388.       IconBlk%!4=newwin%
  4389. H      
  4390. iconrealloc(IconBlk%+24,IconBlk%+28) : 
  4391.  copy indirected data
  4392. &      new%=
  4393. createicon(IconBlk%+4)
  4394.         
  4395.  *** procs for dialogue and reporting errors ***
  4396. errbox(err$,boxes%)
  4397. ErrBlk%!0=0
  4398. $(ErrBlk%+4)=err$+
  4399.  "Wimp_ReportError",ErrBlk%,boxes%,Appl$ 
  4400.  ,click%
  4401. =(click%=1)
  4402. error(forcequit%)
  4403.  button%
  4404.  "Wimp_CloseDown" : 
  4405.  "Hourglass_Smash"
  4406.  forcequit% 
  4407.   button%=2
  4408.   button%=3
  4409. errbox(
  4410. $+" (line "+
  4411. )+")",button%)) 
  4412.  "Wimp_CloseDown"
  4413. complain(msg$)
  4414.  dummy%
  4415. dummy%=
  4416. errbox(msg$,17)
  4417. dialogue(no%,arg1$)
  4418.  b1$,b2$,b3$,mask%,xpos%,ypos%
  4419. b1$=""
  4420. b2$=""
  4421. b3$=""
  4422.  no% 
  4423. '    $Dial_Msg%=
  4424. msg_lookup0("MOD0")
  4425.      b1$=
  4426. msg_lookup0("SAVE")
  4427.      b2$=
  4428. msg_lookup0("DCRD")
  4429.      b3$=
  4430. msg_lookup0("CANC")
  4431. '    $Dial_Msg%=
  4432. msg_lookup0("MOD0")
  4433.      b1$=
  4434. msg_lookup0("DALL")
  4435.      b3$=
  4436. msg_lookup0("CANC")
  4437. !'    $Dial_Msg%=
  4438. msg_lookup0("MOD0")
  4439. "     b1$=
  4440. msg_lookup0("LNEW")
  4441. #     b3$=
  4442. msg_lookup0("CANC")
  4443. %-    $Dial_Msg%=
  4444. msg_lookup1("NORM",arg1$)
  4445.     b2$=
  4446. msg_lookup0("OK")
  4447. ('    $Dial_Msg%=
  4448. msg_lookup0("NUPD")
  4449.     b2$=
  4450. msg_lookup0("OK")
  4451. +'    $Dial_Msg%=
  4452. msg_lookup0("NOSH")
  4453.     b2$=
  4454. msg_lookup0("OK")
  4455. .'    $Dial_Msg%=
  4456. msg_lookup0("NOCH")
  4457.     b2$=
  4458. msg_lookup0("OK")
  4459. 1-    $Dial_Msg%=
  4460. msg_lookup1("TIDY",arg1$)
  4461.     b2$=
  4462. msg_lookup0("OK")
  4463. 4'    $Dial_Msg%=
  4464. msg_lookup0("MOD0")
  4465. 5     b1$=
  4466. msg_lookup0("DCRD")
  4467. 6     b3$=
  4468. msg_lookup0("CANC")
  4469. 8'    $Dial_Msg%=
  4470. msg_lookup0("NSEL")
  4471.     b2$=
  4472. msg_lookup0("OK")
  4473. ;'    $Dial_Msg%=
  4474. msg_lookup0("NFRM")
  4475.     b2$=
  4476. msg_lookup0("OK")
  4477. $Dial_Button1%=b1$
  4478. $Dial_Button2%=b2$
  4479. $Dial_Button3%=b3$
  4480. A)mask%=(1<<2)+(1<<5)+(1<<22)+(&FF<<24)
  4481. (b1$)=0 
  4482.  grey colour -> invisible%
  4483. seticonstate0(DialW%,1,(1<<22)+(&11<<24),mask%)
  4484. seticonstate0(DialW%,1,Dial_ButtonCol1%,mask%)
  4485. (b2$)=0 
  4486. seticonstate0(DialW%,2,(1<<22)+(&11<<24),mask%)
  4487. seticonstate0(DialW%,2,Dial_ButtonCol2%,mask%)
  4488. (b3$)=0 
  4489. seticonstate0(DialW%,3,(1<<22)+(&11<<24),mask%)
  4490. seticonstate0(DialW%,3,Dial_ButtonCol3%,mask%)
  4491. ScrapBlk%!0=DialW%
  4492.  "Wimp_GetWindowState",,ScrapBlk%
  4493. T8xpos%=(ScreenSize_X%-(ScrapBlk%!12-ScrapBlk%!4)) 
  4494. U8ypos%=(ScreenSize_Y%+(ScrapBlk%!16-ScrapBlk%!8)) 
  4495.  "Wimp_CreateMenu",,DialW%,xpos%,ypos%
  4496. LastDialogue%=no%
  4497.  *** heap procs ***
  4498. heap_init
  4499. ]>Heap%=
  4500.  heap starts just after end of allocated memory
  4501.  "OS_ReadMemMapInfo" 
  4502.  PageSize%
  4503.  enlarge wimpslot (1 page) and create private heap in new memory
  4504. SlotSize%=Heap%-&8000
  4505.  "Wimp_SlotSize",SlotSize%+PageSize%,-1 
  4506.  SlotSize%
  4507. HeapEnd%=SlotSize%+&8000
  4508.  HeapEnd%<=Heap% 
  4509.  0,"Can't claim space for heap"
  4510.  "OS_Heap",0,Heap%,,HeapEnd%-Heap%
  4511. heap_get(size%)
  4512.  maxfree%,nrpages%,oldheapend%,ptr%
  4513.  "OS_Heap",1,Heap% 
  4514.  ,,maxfree%
  4515.  size%>maxfree% 
  4516.  largest free block is too small - try to enlarge wimpslot and heap
  4517. lC  nrpages%=1+(size% 
  4518.  PageSize%) : 
  4519.  required # pages of memory
  4520.  "Wimp_SlotSize",SlotSize%+nrpages%*PageSize%,-1 
  4521.  SlotSize%
  4522.   oldheapend%=HeapEnd%
  4523.   HeapEnd%=SlotSize%+&8000
  4524.  "OS_Heap",5,Heap%,,HeapEnd%-oldheapend%
  4525.  "OS_Heap",1,Heap% 
  4526.  ,,maxfree% : 
  4527.  do we have enough now?
  4528.  size%>maxfree% 
  4529. complain(
  4530. msg_lookup0("NOHP"))
  4531.   ptr%=-1
  4532.  "OS_Heap",2,Heap%,,size% 
  4533.  ,,ptr%
  4534. y    =ptr%
  4535. heap_release(ptr%)
  4536.  maxfree%,nrpages%,flg%
  4537.  "OS_Heap",3,Heap%,ptr%
  4538.  "OS_Heap",1,Heap% 
  4539.  ,,maxfree%
  4540.  maxfree%>PageSize% 
  4541.  more than 1 page free - try to shrink heap (page by page)
  4542. ,  nrpages%=0 : 
  4543.  # pages of memory freed
  4544. 1    
  4545.  "XOS_Heap",5,Heap%,,-PageSize% 
  4546.  ;flg%
  4547.  (flg% 
  4548.  1)=0 
  4549.       nrpages%+=1
  4550.         
  4551.  (flg% 
  4552.  1)<>0
  4553.  nrpages%>0 
  4554. 4    
  4555.  successfully shrunk heap - shrink WimpSlot
  4556. F    
  4557.  "Wimp_SlotSize",SlotSize%-nrpages%*PageSize%,-1 
  4558.  SlotSize%
  4559.      HeapEnd%=SlotSize%+&8000
  4560.  "OS_Heap",5,Heap%,,(HeapEnd%-Heap%)-Heap%!12
  4561.  *** service procs; interface with SWIs, etc. ***
  4562.  --- change a variable with given difference, but keep inside bounds ---
  4563. changevar(
  4564.  var%,diff%,up%,low%,high%)
  4565.  oldval%
  4566. oldval%=var%
  4567.  up% 
  4568.   var%+=diff%
  4569.   var%-=diff%
  4570.  var%>high% 
  4571.  var%=high%
  4572.  var%<low% 
  4573.  var%=low%
  4574.  return TRUE if changed
  4575. =(oldval%<>var%) 
  4576. readvarval(var$)
  4577.  len%
  4578.  "OS_ReadVarVal",var$,ScrapBlk%,256,0 
  4579.  ,,len%
  4580. ScrapBlk%?len%=13
  4581. =$(ScrapBlk%)
  4582.  --- return name of icon to display in browser window ---
  4583. windowicon(wflags%,open%)
  4584.  sname$,tbar%,hscroll%,vscroll%
  4585.  wflags% 
  4586.  (1<<31) 
  4587. !  tbar%=(wflags% 
  4588.  (1<<26))>0
  4589. $  hscroll%=(wflags% 
  4590.  (1<<30))>0
  4591. $  vscroll%=(wflags% 
  4592.  (1<<28))>0
  4593.    tbar%=(wflags% 
  4594.  (1<<0))>0
  4595. #  hscroll%=(wflags% 
  4596.  (1<<3))>0
  4597. #  vscroll%=(wflags% 
  4598.  (1<<2))>0
  4599. sname$="Swin_"
  4600.  tbar% 
  4601.  sname$+="t"
  4602.  hscroll% 
  4603.  sname$+="h"
  4604.  vscroll% 
  4605.  sname$+="v"
  4606.  open% 
  4607.  sname$+="o"
  4608. =sname$
  4609. modevar(mode%,v%)
  4610.  val%
  4611.  "OS_ReadModeVariable",mode%,v% 
  4612.  ,,val%
  4613.     =val%
  4614. readscreenvars
  4615.  xeig%,yeig%,xpixels%,ypixels%
  4616. xeig%=
  4617. modevar(-1,4)
  4618. yeig%=
  4619. modevar(-1,5)
  4620. xpixels%=
  4621. modevar(-1,11)
  4622. ypixels%=
  4623. modevar(-1,12)
  4624. 9PixToOS_X%=1<<xeig% : 
  4625.  # OS units that 1 pixel takes
  4626. PixToOS_Y%=1<<yeig%
  4627. EScreenSize_X%=(xpixels%+1)*PixToOS_X% : 
  4628.  screen size in OS units
  4629. )ScreenSize_Y%=(ypixels%+1)*PixToOS_Y%
  4630.  grid size must be multiple of # OS units per pixel
  4631.  Grid_SizeX%<PixToOS_X% 
  4632.   Grid_SizeX%=PixToOS_X%
  4633. -  Grid_SizeX%-=(Grid_SizeX% 
  4634.  PixToOS_X%)
  4635.  Grid_SizeY%<PixToOS_Y% 
  4636.   Grid_SizeY%=PixToOS_Y%
  4637. -  Grid_SizeY%-=(Grid_SizeY% 
  4638.  PixToOS_Y%)
  4639. seticontext(28,
  4640. (Grid_SizeX%))
  4641. seticontext(29,
  4642. (Grid_SizeY%))
  4643.  Grid_PosX%<PixToOS_X% 
  4644.   Grid_PosX%=PixToOS_X%
  4645. +  Grid_PosX%-=(Grid_PosX% 
  4646.  PixToOS_X%)
  4647.  Grid_PosY%<PixToOS_Y% 
  4648.   Grid_PosY%=PixToOS_Y%
  4649. +  Grid_PosY%-=(Grid_PosY% 
  4650.  PixToOS_Y%)
  4651. seticontext(30,
  4652. (Grid_PosX%))
  4653. seticontext(31,
  4654. (Grid_PosY%))
  4655. DTemplW_MaxCol%=(ScreenSize_X%-100-IcInfo_Width%) 
  4656.  TemplW_IconX%
  4657. setcaret(window%,icon%)
  4658.  icon%>=0 
  4659.   ScrapBlk%!0=window%
  4660.   ScrapBlk%!4=icon%
  4661.  "Wimp_GetIconState",,ScrapBlk%
  4662.   l%=
  4663. ($(ScrapBlk%!28))
  4664.  "Wimp_SetCaretPosition",window%,icon%,,,-1,l%
  4665.  invisible caret
  4666.  "Wimp_SetCaretPosition",window%,-1,0,0,1<<25
  4667. setmouseshape(i%)
  4668.  n$,xoff%,yoff%
  4669.  0 : 
  4670.  default pointer shape
  4671.     n$="ptr_default"
  4672.     xoff%=0
  4673.     yoff%=0
  4674.  1 : 
  4675.  hand pointer for moving icons
  4676.     n$="ptr_hand"
  4677.     xoff%=7
  4678.     yoff%=6
  4679.  2 : 
  4680.  pointer for resizing icons, dragging top side
  4681.     n$="ptr_sizet"
  4682.     xoff%=7
  4683.     yoff%=6
  4684.  3 : 
  4685.  pointer for resizing icons, dragging right side
  4686.     n$="ptr_sizer"
  4687.     xoff%=5
  4688.     yoff%=5
  4689.  4 : 
  4690.  pointer for resizing icons, dragging bottom side
  4691.     n$="ptr_sizeb"
  4692.     xoff%=7
  4693.     yoff%=4
  4694.  5 : 
  4695.  pointer for resizing icons, dragging left side
  4696.     n$="ptr_sizel"
  4697.     xoff%=10
  4698.     yoff%=5
  4699. Mouse_Ptt%!0=&03020100
  4700.  i%=0 
  4701.  "Wimp_SpriteOp",36,,n$,&2,xoff%,yoff%,0,Mouse_Ptt%
  4702.  "OS_SpriteOp",&100+36,SysSprites%,n$,&2,xoff%,yoff%,0,Mouse_Ptt%
  4703. MouseShape%=i%
  4704.  --- re-allocate indirected icon data and increase font count ---
  4705. iconrealloc(flagptr%,data%)
  4706.  flags%,s$,s%,len%
  4707. flags%=flagptr%!0
  4708.  (flags% 
  4709.  &800100)=&100 
  4710.   s$=
  4711. str(data%!0)
  4712. ?  len%=data%!8              : 
  4713.  don't allocate actual size!
  4714.  len%>256 
  4715.  len%=256 : 
  4716.  Basic can't handle longer strings
  4717.   s%=
  4718. heap_get(len%)
  4719.  s%>0 
  4720.     $(s%)=
  4721. s$,len%-1)
  4722.     data%!0=s%
  4723. $&    
  4724.  (flags% 
  4725.  (data%!4>0) 
  4726. %)      
  4727.  re-allocate validation string
  4728.       s$=
  4729. str(data%!4)
  4730.       s%=
  4731. heap_get(
  4732.  s$+1)
  4733.       
  4734.  s%>0 
  4735.         $(s%)=s$
  4736.         data%!4=s%
  4737.       
  4738.         data%!4=-1
  4739.       
  4740. .        
  4741. 0G    
  4742.  allocation failed - make non-indirected and store first chars
  4743. 1*    flagptr%!0=flagptr%!0 
  4744.  (1<<8))
  4745.     $data%=
  4746. s$,11)
  4747.  (flags% 
  4748.  &800040)=&40 
  4749. 6!  FontUsage%((flags%)>>24)+=1
  4750.  --- release indirected icon data and decrease font count ---
  4751. iconrelease(flags%,data%)
  4752.  (flags% 
  4753.  &800100)=&100 
  4754. heap_release(data%!0)
  4755.  (flags% 
  4756.  (data%!(4)<>-1) 
  4757. ?#    
  4758.  release validation string
  4759. heap_release(data%!4)
  4760.  (flags% 
  4761.  &800040)=&40 
  4762. font_lose(flags%>>24)
  4763.  --- open a window ---
  4764.        pos% = 0 -> at current position
  4765.               1 -> centered to screen
  4766.               2 -> centered unless already open
  4767.               3 -> in topleft corner unless already open
  4768.               4 -> in topright corner unless already open
  4769. openwindow(handle%,pos%)
  4770.  notopen%,cx%,cy%,dx%,dy%
  4771. ScrapBlk%!0=handle%
  4772.  "Wimp_GetWindowState",,ScrapBlk%
  4773. R)notopen%=((ScrapBlk%!32 
  4774.  (1<<16))=0)
  4775. S    dx%=0
  4776. T    dy%=0
  4777.  pos% 
  4778.  (pos%=1) 
  4779.  notopen% 
  4780. X#      
  4781.  center window to screen
  4782.       cx%=ScreenSize_X% 
  4783.       cy%=ScreenSize_Y% 
  4784. [0      dx%=cx%-(ScrapBlk%!12+ScrapBlk%!4) 
  4785. \0      dy%=cy%-(ScrapBlk%!16+ScrapBlk%!8) 
  4786. ]        
  4787.  notopen% 
  4788.       dx%=-ScrapBlk%!4
  4789. a(      dy%=ScreenSize_Y%-ScrapBlk%!16
  4790. b        
  4791.  notopen% 
  4792. e(      dx%=ScreenSize_X%-ScrapBlk%!12
  4793. f(      dy%=ScreenSize_Y%-ScrapBlk%!16
  4794. g        
  4795. ScrapBlk%!4=ScrapBlk%!4+dx%
  4796. ScrapBlk%!8=ScrapBlk%!8+dy%
  4797. k!ScrapBlk%!12=ScrapBlk%!12+dx%
  4798. l!ScrapBlk%!16=ScrapBlk%!16+dy%
  4799. ScrapBlk%!28=-1
  4800.  "Wimp_OpenWindow",,ScrapBlk%
  4801.  handle%=OptionsW% 
  4802. openpane(OptPaneW%,-1,ScrapBlk%!4,ScrapBlk%!16)
  4803. closewindow(handle%)
  4804. ScrapBlk%!0=handle%
  4805.  "Wimp_CloseWindow",,ScrapBlk%
  4806.  handle% 
  4807.  TemplW%
  4808.     ScrapBlk%!0=IcInfoW%
  4809. {(    
  4810.  "Wimp_CloseWindow",,ScrapBlk%
  4811.     ScrapBlk%!0=PaletteW%
  4812. }(    
  4813.  "Wimp_CloseWindow",,ScrapBlk%
  4814.  NrTemplates%>0 
  4815. !      
  4816.  i%=0 
  4817.  NrTemplates%-1
  4818.         
  4819. closetemplate(i%)
  4820.       
  4821.         
  4822.  OptionsW%
  4823.     ScrapBlk%!0=OptPaneW%
  4824. (    
  4825.  "Wimp_CloseWindow",,ScrapBlk%
  4826. openpane(handle%,behind%,pxmin%,pymax%)
  4827.  dx%,dy%
  4828.  handle% 
  4829.  OptPaneW%
  4830. A    dx%=16  : 
  4831.  distance from topleft corner of parent window
  4832.     dy%=-16
  4833. ScrapBlk%!0=handle%
  4834.  "Wimp_GetWindowState",,ScrapBlk%
  4835. 6ScrapBlk%!12=pxmin%+dx%+(ScrapBlk%!12-ScrapBlk%!4)
  4836. 5ScrapBlk%!8=pymax%+dy%-(ScrapBlk%!16-ScrapBlk%!8)
  4837. ScrapBlk%!4=pxmin%+dx%
  4838. ScrapBlk%!16=pymax%+dy%
  4839. ScrapBlk%!28=behind%
  4840.  "Wimp_OpenWindow",,ScrapBlk%
  4841. opentemplate(no%)
  4842.  no%>=0 
  4843. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  4844.  "Wimp_GetWindowState",,ScrapBlk%
  4845.  (ScrapBlk%!32 
  4846.  (1<<16))=0 
  4847.     ScrapBlk%!28=-1
  4848. '    
  4849.  "Wimp_OpenWindow",,ScrapBlk%
  4850. <    $(TemplNames%+28*no%+14)=
  4851. windowicon(ScrapBlk%!32,1)
  4852. '    
  4853. seticonstate0(TemplW%,no%,0,0)
  4854. 8    
  4855.  TemplatesOpen%=0 
  4856.  PollMask%=PollMask% 
  4857.     TemplatesOpen%+=1
  4858. *    
  4859. setcaret(TemplHandle%!(4*no%),-1)
  4860. closetemplate(no%)
  4861.  no%>=0 
  4862. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  4863.  "Wimp_GetWindowState",,ScrapBlk%
  4864.  (ScrapBlk%!32 
  4865.  (1<<16))>0 
  4866. (    
  4867.  "Wimp_CloseWindow",,ScrapBlk%
  4868. +    
  4869.  "Wimp_GetWindowState",,ScrapBlk%
  4870. <    $(TemplNames%+28*no%+14)=
  4871. windowicon(ScrapBlk%!32,0)
  4872. '    
  4873. seticonstate0(TemplW%,no%,0,0)
  4874. ?    
  4875.  TemplHandle%!(4*no%)=IcEd_Win% 
  4876. closewindow(IcEdW%)
  4877. A    
  4878.  TemplHandle%!(4*no%)=WinEd_Win% 
  4879. closewindow(WinEdW%)
  4880.     TemplatesOpen%-=1
  4881. 4    
  4882.  TemplatesOpen%=0 
  4883.  PollMask%=PollMask% 
  4884.  --- convert string to lowercase ---
  4885. locase(s$)
  4886.  i%=1 
  4887.   a%=
  4888. s$,i%,1))
  4889.  (a%>=65)
  4890. (a%<=90) 
  4891. s$,i%,1)=
  4892. (a%+32)
  4893.  --- convert string to uppercase ---
  4894. upcase(s$)
  4895.  i%=1 
  4896.   a%=
  4897. s$,i%,1))
  4898.  (a%>=97)
  4899. (a%<=122) 
  4900. s$,i%,1)=
  4901. (a%-32)
  4902.  --- split off leaf name from a filename ---
  4903. leafname(f$)
  4904.  p%,q%
  4905.   p%=q%+1
  4906.   q%=
  4907. f$,".",p%)
  4908.  q%=0
  4909. f$,p%)
  4910.  --- split off directory name from a filename ---
  4911. dirname(f$)
  4912.  p%,q%
  4913. f$,".",p%)
  4914.  q% > 0 
  4915.  p%=q%+1
  4916.  q%=0
  4917. f$,p%-2)
  4918.  --- get the control-terminated string at the given address ---
  4919. str(s%)
  4920.  i%,n$
  4921.  (s%?i%>31) 
  4922.  (i%<255)
  4923.   n$+=
  4924. (s%?i%)
  4925.   i%+=1
  4926. fileexists(f$)
  4927.  type%
  4928. type%=0
  4929. (f$)>0 
  4930.  "OS_File",17,f$ 
  4931.  type%
  4932. =(type%=1)
  4933.  --- set icon state in a template window ---
  4934. seticonstate(window%,icon%,eor%,clr%)
  4935.  oldflags%,newflags%
  4936. ScrapBlk%!0=window%
  4937. ScrapBlk%!4=icon%
  4938.  check if font usage is changing
  4939.  "Wimp_GetIconState",,ScrapBlk%
  4940. oldflags%=ScrapBlk%!24
  4941. )newflags%=(oldflags% 
  4942.  clr%) 
  4943.  eor%
  4944.  (newflags% 
  4945.  &800040)=&40 
  4946. "  FontUsage%(newflags%>>24)+=1
  4947.  (oldflags% 
  4948.  &800040)=&40 
  4949. font_lose(oldflags%>>24)
  4950. ScrapBlk%!8=eor%
  4951. ScrapBlk%!12=clr%
  4952.  Support%=2 
  4953.  "AEH_SetIconState",,ScrapBlk%
  4954.  "Wimp_SetIconState",,ScrapBlk%
  4955.  --- set icon state in one of TemplEd's own windows ---
  4956. seticonstate0(window%,icon%,eor%,clr%)
  4957.  oldflags%,newflags%
  4958. ScrapBlk%!0=window%
  4959. ScrapBlk%!4=icon%
  4960. ScrapBlk%!8=eor%
  4961. ScrapBlk%!12=clr%
  4962.  "Wimp_SetIconState",,ScrapBlk%
  4963. selecticon(window%,icon%,f%)
  4964.  oldflag%
  4965. ScrapBlk%!0=window%
  4966. ScrapBlk%!4=icon%
  4967.  "Wimp_GetIconState",,ScrapBlk%
  4968. %oldflag%=(ScrapBlk%!24) 
  4969.  (1<<21)
  4970.   ScrapBlk%!8=1<<21
  4971.   ScrapBlk%!8=0
  4972. ScrapBlk%!12=1<<21
  4973.  oldflag%<>ScrapBlk%!8 
  4974.  only set when changing
  4975.  Support%=2 
  4976. ('   
  4977.  "AEH_SetIconState",,ScrapBlk%
  4978. *(   
  4979.  "Wimp_SetIconState",,ScrapBlk%
  4980. iconselected(window%,icon%)
  4981. ScrapBlk%!0=window%
  4982. ScrapBlk%!4=icon%
  4983.  "Wimp_GetIconState",,ScrapBlk%
  4984. 3#=((ScrapBlk%!24) 
  4985.  (1<<21)) > 0
  4986. shadeicon(window%,icon%,f%)
  4987.  oldflag%
  4988. ScrapBlk%!0=window%
  4989. ScrapBlk%!4=icon%
  4990.  "Wimp_GetIconState",,ScrapBlk%
  4991. :%oldflag%=(ScrapBlk%!24) 
  4992.  (1<<22)
  4993.   ScrapBlk%!8=(1<<22)
  4994.   ScrapBlk%!8=0
  4995. ScrapBlk%!12=1<<22
  4996.  oldflag%<>ScrapBlk%!8 
  4997.  only set when changing
  4998.  Support%=2 
  4999. D'   
  5000.  "AEH_SetIconState",,ScrapBlk%
  5001. F(   
  5002.  "Wimp_SetIconState",,ScrapBlk%
  5003. iconshaded(window%,icon%)
  5004. ScrapBlk%!0=window%
  5005. ScrapBlk%!4=icon%
  5006.  "Wimp_GetIconState",,ScrapBlk%
  5007. O#=((ScrapBlk%!24) 
  5008.  (1<<22)) > 0
  5009.  --- store pointer to indirected text icon (for use in PROCseticontext) ---
  5010. linkicontext(index%,wbuf%,icon%)
  5011. S,IconText%(index%)=wbuf%!(92+icon%*32+20)
  5012. T!IconTextWhdl%(index%)=wbuf%!0
  5013. IconTextIhdl%(index%)=icon%
  5014. seticontext(index%,text$)
  5015. $(IconText%(index%))=text$
  5016. seticonstate0(IconTextWhdl%(index%),IconTextIhdl%(index%),0,0)
  5017.  --- store pointer to text of colour-select-box ---
  5018. linkcseltext(index%,wbuf%,icon%)
  5019. _,CselText%(index%)=wbuf%!(92+icon%*32+20)
  5020. `!CselTextWhdl%(index%)=wbuf%!0
  5021. CselTextIhdl%(index%)=icon%
  5022.  --- set colour number in colour-select-box ---
  5023. setcolourbox(index%,colour%)
  5024.  c$,boxcol%
  5025. (colour%)
  5026.  colour%=&FF 
  5027.  c$="--"
  5028. $(CselText%(index%))=c$
  5029. boxcol%=&07
  5030.  colour%<16 
  5031. l2  boxcol%=(colour%<<4)+InverseColour%(colour%)
  5032. boxcol%=boxcol%<<24
  5033. seticonstate0(CselTextWhdl%(index%),CselTextIhdl%(index%),boxcol%,&FF<<24)
  5034.  --- change colour number ---
  5035. changecolourbox(index%,
  5036.  colour%,diff%,up%,bigrange%)
  5037.  newcolour%
  5038.  up% 
  5039.   newcolour%=colour%+diff%
  5040.   newcolour%=colour%-diff%
  5041.  (newcolour% 
  5042.  &FF)=255 
  5043.  newcolour%=newcolour%+diff%
  5044.  bigrange% 
  5045. |E  newcolour%=newcolour% 
  5046.  &FF        : 
  5047.  colours range from 0-255
  5048.  newcolour%<0 
  5049.  newcolour%=0    : 
  5050.  colours range from 0-15
  5051.  newcolour%>&F 
  5052.  newcolour%=&F
  5053.  newcolour%<>colour% 
  5054.   colour%=newcolour%
  5055. setcolourbox(index%,colour%)
  5056.  --- find number of template corresponding with a window handle ---
  5057.  returns -1 if not a user template, -2 if it's the palette window
  5058. whichtemplate(handle%)
  5059.  (TemplHandle%!(4*i%)<>handle%) 
  5060.  (i%<NrTemplates%)
  5061.   i%+=1
  5062.  i%=NrTemplates% 
  5063.  handle%=PaletteW% 
  5064.     i%=-2
  5065. ;    i%=-1 : 
  5066.  handle does not belong to template window
  5067. settitlebar(handle%,textptr%,title$)
  5068.  xmax%,ymax%
  5069. $(textptr%)=title$
  5070. ScrapBlk%!0=handle%
  5071.  "Wimp_GetWindowOutline",,ScrapBlk%
  5072. xmax%=ScrapBlk%!12
  5073. ymax%=ScrapBlk%!16
  5074.  "Wimp_GetWindowState",,ScrapBlk%
  5075.  (ScrapBlk%!32 
  5076.  (1<<16)) 
  5077.  "Wimp_ForceRedraw",-1,ScrapBlk%!4,ScrapBlk%!16,xmax%,ymax%
  5078.  --- delete all selected icons in a window ---
  5079. deleteiconsel(window%,default%)
  5080. sel_get(window%)
  5081.  NrSelected%>0 
  5082.  i%=0 
  5083.  NrSelected%-1
  5084. /    
  5085. deleteicon(window%,SelBlk%!(4*i%),1,1)
  5086.  nothing selected - delete icon no. <default%>
  5087.  default%>=0 
  5088. deleteicon(window%,default%,1,1)
  5089. NrSelected%=0
  5090. deleteicon(win%,icon%,release%,adjustvars%)
  5091. ScrapBlk%!0=win%
  5092. ScrapBlk%!4=icon%
  5093.  "Wimp_GetIconState",,ScrapBlk%
  5094.  release% 
  5095. iconrelease(ScrapBlk%!24,ScrapBlk%+28)
  5096.  "Wimp_DeleteIcon",,ScrapBlk%
  5097.  "Wimp_ForceRedraw",win%,ScrapBlk%!8-20,ScrapBlk%!12-20,ScrapBlk%!16+20,ScrapBlk%!20+20
  5098.  adjustvars% 
  5099.  (win%=IcEd_Win%) 
  5100.  (icon%=IcEd_Icon%) 
  5101.     IcEd_Icon%=-1000
  5102.  (win%=LastMenu_Win%) 
  5103.  (icon%=LastMenu_Icon%) 
  5104.     LastMenu_Icon%=-1
  5105. setchanged(
  5106. createicon(blk%)
  5107.  dxmin%,dymin%,dxmax%,dymax%,handle%
  5108.  Grid_PosLock% 
  5109. )  dxmin%=
  5110. griddiff(blk%!4,Grid_PosX%)
  5111. )  dymin%=
  5112. griddiff(blk%!8,Grid_PosY%)
  5113.   blk%!4=blk%!4-dxmin%
  5114.   blk%!8=blk%!8-dymin%
  5115.   blk%!12=blk%!12-dxmin%
  5116.   blk%!16=blk%!16-dymin%
  5117.  Grid_SizeLock% 
  5118. *  dxmin%=
  5119. griddiff(blk%!4,Grid_SizeX%)
  5120. *  dymin%=
  5121. griddiff(blk%!8,Grid_SizeY%)
  5122. +  dxmax%=
  5123. griddiff(blk%!12,Grid_SizeX%)
  5124. +  dymax%=
  5125. griddiff(blk%!16,Grid_SizeY%)
  5126. J  dxmin%=
  5127. griddiff(blk%!4,PixToOS_X%): 
  5128.  round coords to screen pixels
  5129. )  dymin%=
  5130. griddiff(blk%!8,PixToOS_Y%)
  5131. *  dxmax%=
  5132. griddiff(blk%!12,PixToOS_X%)
  5133. *  dymax%=
  5134. griddiff(blk%!16,PixToOS_Y%)
  5135. blk%!4=blk%!4-dxmin%
  5136. blk%!8=blk%!8-dymin%
  5137. blk%!12=blk%!12-dxmax%
  5138. blk%!16=blk%!16-dymax%
  5139.  blk%!4>=blk%!12 
  5140.  blk%!12=blk%!4+4
  5141.  blk%!8>=blk%!16 
  5142.  blk%!16=blk%!8+4
  5143.  "Wimp_CreateIcon",,blk% 
  5144.  handle%
  5145.  "Wimp_ForceRedraw",blk%!0,blk%!4-12,blk%!8-12,blk%!12+12,blk%!16+12
  5146.  handle%>MaxIcons% 
  5147. complain(
  5148. msg_lookup0("MICX"))
  5149. setchanged(
  5150. =handle%
  5151.  --- calculate distance from nearest gridpoint ---
  5152. griddiff(c%,gridsize%)
  5153.  diff%
  5154. diff%=c% 
  5155.  gridsize%
  5156.  c%<0 
  5157.  (-diff%)>(gridsize%>>1) 
  5158.  diff%+=gridsize%
  5159.  diff%>(gridsize%>>1) 
  5160.  diff%-=gridsize%
  5161. =diff%
  5162.  --- copy all selected icons in a window ---
  5163. copyiconsel(window%,
  5164.  icon%,dir%)
  5165.  i%,xmin%,ymin%,xmax%,ymax%,dx%,dy%,handle%
  5166. sel_get(window%)
  5167.  (NrSelected%=0) 
  5168.  (icon%>=0) 
  5169.   SelBlk%!0=icon%
  5170.   NrSelected%=1
  5171. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5172.  dir% 
  5173.  0 : dx%=16 : dy%=-16        : 
  5174.  fixed distance (a bit lower+right)
  5175.  1 : dx%=0 : dy%=ymax%-ymin% : 
  5176.  copy up
  5177.  2 : dx%=0 : dy%=ymin%-ymax% : 
  5178.  copy down
  5179.  3 : dx%=xmin%-xmax% : dy%=0 : 
  5180.  copy left
  5181.  4 : dx%=xmax%-xmin% : dy%=0 : 
  5182.  copy right
  5183.  NrSelected%>0 
  5184.  i%=0 
  5185.  NrSelected%-1
  5186.  copy icon
  5187.     ScrapBlk%!0=window%
  5188. "    ScrapBlk%!4=SelBlk%!(4*i%)
  5189.     )    
  5190.  "Wimp_GetIconState",,ScrapBlk%
  5191.     ScrapBlk%!4=window%
  5192. #    ScrapBlk%!8=ScrapBlk%!8+dx%
  5193. %    ScrapBlk%!12=ScrapBlk%!12+dy%
  5194. %    ScrapBlk%!16=ScrapBlk%!16+dx%
  5195. %    ScrapBlk%!20=ScrapBlk%!20+dy%
  5196. H    
  5197. iconrealloc(ScrapBlk%+24,ScrapBlk%+28) : 
  5198.  copy indirected data
  5199. (    handle%=
  5200. createicon(ScrapBlk%+4)
  5201. 5    
  5202.  deselect originals - copies remain selected
  5203. -    
  5204. selecticon(window%,SelBlk%!(4*i%),0)
  5205.  icon%>=0 
  5206.  icon%=handle%
  5207. sel_get(window%)
  5208.  --- replace window definition with new one ---
  5209. redefinewindow(wbuf%,setchanged%)
  5210.  oldhandle%,no%,wasopen%,hadcaret%,newhandle%
  5211. oldhandle%=wbuf%!0
  5212.  "Wimp_GetCaretPosition",,ScrapBlk%
  5213. &hadcaret%=(ScrapBlk%!0=oldhandle%)
  5214. "no%=
  5215. whichtemplate(oldhandle%)
  5216. ScrapBlk%!0=oldhandle%
  5217.  "Wimp_GetWindowState",,ScrapBlk%
  5218. "%wasopen%=(ScrapBlk%!32) 
  5219.  (1<<16)
  5220.  "Wimp_DeleteWindow",,wbuf%
  5221.  "Wimp_CreateWindow",,wbuf%+4 
  5222.  newhandle%
  5223. wbuf%!0=newhandle%
  5224.  no%<>-1 
  5225. '%  TemplHandle%!(4*no%)=newhandle%
  5226.  oldhandle%=IcEd_Win% 
  5227.   IcEd_Win%=newhandle%
  5228.  IcEd_Icon%>=0 
  5229. ,3    IcEd_Icon%=-1000 : 
  5230.  invalidate icon handle
  5231.  oldhandle%=WinEd_Win% 
  5232.  WinEd_Win%=newhandle%
  5233.  oldhandle%=LastMenu_Win% 
  5234.   LastMenu_Win%=newhandle%
  5235.   LastMenu_Icon%=-1
  5236.  wasopen% 
  5237.  "Wimp_OpenWindow",,wbuf%
  5238.  hadcaret% 
  5239.  "Wimp_SetCaretPosition",newhandle%,-1,0,0,1<<25
  5240. :;$(TemplNames%+28*no%+14)=
  5241. windowicon(wbuf%!32,wasopen%)
  5242. seticonstate0(TemplW%,no%,0,0)
  5243.  setchanged% 
  5244. setchanged(
  5245. =newhandle%
  5246.  --- replace icon definition with new one ---
  5247. redefineicon(window%,icon%,blk%)
  5248.  newicon%
  5249. deleteicon(window%,icon%,0,0)
  5250.  new icon data must start at blk%+8 (as returned by Wimp_GetIconState)
  5251. blk%!4=window%
  5252. E newicon%=
  5253. createicon(blk%+4)
  5254.  (window%=IcEd_Win%) 
  5255.  (icon%=IcEd_Icon%) 
  5256.   IcEd_Icon%=newicon%
  5257.  (window%=LastMenu_Win%) 
  5258.  (icon%=LastMenu_Icon%) 
  5259.   LastMenu_Icon%=newicon%
  5260. =newicon%
  5261.  --- renumber an icon; new number is equal to NextIconNr% ---
  5262. renumbericon(
  5263.  window%,icon%)
  5264.  i%,ip1%,ip2%,temp%
  5265. WinBlk%!0=window%
  5266.  "Wimp_GetWindowInfo",,WinBlk%
  5267.  icon%>=WinBlk%!88 
  5268.  icon%=WinBlk%!88-1
  5269.  NextIconNr%>=WinBlk%!88 
  5270.  NextIconNr%=WinBlk%!88-1
  5271. ip1%=WinBlk%+92+icon%*32
  5272. V"ip2%=WinBlk%+92+NextIconNr%*32
  5273.  swap icon data blocks in window definition
  5274.  i%=0 
  5275.   temp%=ip1%!i%
  5276.   ip1%!i%=ip2%!i%
  5277.   ip2%!i%=temp%
  5278. ]&window%=
  5279. redefinewindow(WinBlk%,1)
  5280.  --- renumber selected icons, ordering based on topleft coords ---
  5281. renumbericonsel(
  5282.  window%)
  5283.  i%,j%,f%,l%
  5284. sel_get(window%)
  5285. sel_sort(window%,1,1,0,0,0,1)
  5286.  "Wimp_WhichIcon",window%,SelBlk2%,(1<<21)+(1<<23),1<<21
  5287. WinBlk%!0=window%
  5288.  "Wimp_GetWindowInfo",,WinBlk%
  5289. hBf%=NextIconNr%               : 
  5290.  first number of new numbering
  5291. i0l%=NextIconNr%+NrSelected%-1 : 
  5292.  last number
  5293.  l%>=WinBlk%!88 
  5294. kK  l%=WinBlk%!88-1            : 
  5295.  make sure new numbers are within range
  5296.   f%=l%-(NrSelected%-1)
  5297.  i%=0 
  5298.  NrSelected%-1
  5299.  replace icon with i%-th icon from sorted selection
  5300. replaceicon(WinBlk%,f%+i%,window%,SelBlk%!(4*i%))
  5301. iconselected(window%,f%+i%) 
  5302. sM    
  5303.  data of unselected icon overwritten - find new number for this icon
  5304. t8    
  5305.  (SelBlk2%!(4*j%)>=f%) 
  5306.  (SelBlk2%!(4*j%)<=l%)
  5307.       j%+=1
  5308. v        
  5309. w;    
  5310. replaceicon(WinBlk%,SelBlk2%!(4*j%),window%,f%+i%)
  5311.     j%+=1
  5312. {&window%=
  5313. redefinewindow(WinBlk%,1)
  5314. NextIconNr%=l%+1
  5315.  --- set selected icons to same size as topleft icon ---
  5316. samesizeiconsel(window%,default%,dim%)
  5317.  i%,xsize%,ysize%,handle%
  5318. sel_get(window%)
  5319.  (NrSelected%=0) 
  5320.  (default%>=0) 
  5321.   SelBlk%!0=default%
  5322.   NrSelected%=1
  5323.  NrSelected%>0 
  5324. sel_sort(window%,1,1,0,0,0,1)
  5325.   IconBlk%!0=window%
  5326.   IconBlk%!4=SelBlk%!0
  5327.  "Wimp_GetIconState",,IconBlk%
  5328. #  xsize%=IconBlk%!16-IconBlk%!8
  5329. $  ysize%=IconBlk%!20-IconBlk%!12
  5330.  i%=0 
  5331.  NrSelected%-1
  5332.     IconBlk%!0=window%
  5333. !    IconBlk%!4=SelBlk%!(4*i%)
  5334. (    
  5335.  "Wimp_GetIconState",,IconBlk%
  5336. 1    
  5337.  dim%<>2 
  5338.  IconBlk%!16=IconBlk%!8+xsize%
  5339. 2    
  5340.  dim%<>1 
  5341.  IconBlk%!20=IconBlk%!12+ysize%
  5342. >    handle%=
  5343. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5344.  --- in wbuf%, replace data for icon ic1% with data of icon ic2% ---
  5345. replaceicon(wbuf%,ic1%,window%,ic2%)
  5346.  ib%,temp1%,temp2%
  5347. ib%=wbuf%+92+32*ic1%
  5348. ?temp1%=ib%!(-8) : 
  5349.  save 2 words just before the icon block
  5350. temp2%=ib%!(-4)
  5351. ib%!(-8)=window%
  5352. ib%!(-4)=ic2%
  5353.  "Wimp_GetIconState",,ib%-8 : 
  5354.  get icon data block
  5355. +ib%!(-8)=temp1% : 
  5356.  restore the 2 words
  5357. ib%!(-4)=temp2%
  5358.  --- update contents of icon info window ---
  5359. icinf_update
  5360.  no%,t$,i$,xmin$,xmax$,ymin$,ymax$,s$,mx%,my%,m$
  5361.  showicondata%,xmin%,xmax%,ymin%,ymax%
  5362.  "Wimp_GetPointerInfo",,PtrInfo%
  5363. #no%=
  5364. whichtemplate(PtrInfo%!12)
  5365.     t$=""
  5366.     i$=""
  5367. xmin$=""
  5368. xmax$=""
  5369. ymin$=""
  5370. ymax$=""
  5371.     s$=""
  5372.     m$=""
  5373. showicondata%=
  5374.  (no%>=0) 
  5375.   t$=$(TemplNames%+28*no%)
  5376.  PtrInfo%!16>=-1 
  5377.     ScrapBlk%!0=PtrInfo%!12
  5378. +    
  5379.  "Wimp_GetWindowState",,ScrapBlk%
  5380. 1    mx%=PtrInfo%!0-(ScrapBlk%!4-ScrapBlk%!20)
  5381. 2    my%=PtrInfo%!4-(ScrapBlk%!16-ScrapBlk%!24)
  5382.     m$=
  5383. (mx%)+","+
  5384. (my%)
  5385.  Drag_Type% 
  5386.       
  5387. K        
  5388.  moving/resizing icon(s) - show current coordinates of dragbox
  5389.         i$="..."
  5390. -        xmin%=mx%-(Drag_Ptrx%-DragBlk%!8)
  5391. .        ymin%=my%-(Drag_Ptry%-DragBlk%!12)
  5392. &        xmax%=xmin%+Drag_BoxSizex%
  5393. &        ymax%=ymin%+Drag_BoxSizey%
  5394.         showicondata%=
  5395.       
  5396. D        
  5397.  resizing icon(s) - show current coordinates of dragbox
  5398.         i$="..."
  5399.         xmin%=Drag_Box0x%
  5400.         ymin%=Drag_Box0y%
  5401. &        xmax%=xmin%+Drag_BoxSizex%
  5402. &        ymax%=ymin%+Drag_BoxSizey%
  5403.         
  5404.  MouseShape% 
  5405. 2          
  5406.  2 : ymax%+=(PtrInfo%!4-Drag_Ptry%)
  5407. 2          
  5408.  3 : xmax%+=(PtrInfo%!0-Drag_Ptrx%)
  5409. 2          
  5410.  4 : ymin%+=(PtrInfo%!4-Drag_Ptry%)
  5411. 2          
  5412.  5 : xmin%+=(PtrInfo%!0-Drag_Ptrx%)
  5413.         
  5414.         showicondata%=
  5415.       
  5416. -        
  5417.  show data of icon under pointer
  5418.         
  5419.  PtrInfo%!16>=0 
  5420.           i$=
  5421. (PtrInfo%!16)
  5422. %          ScrapBlk%!0=PtrInfo%!12
  5423. %          ScrapBlk%!4=PtrInfo%!16
  5424. /          
  5425.  "Wimp_GetIconState",,ScrapBlk%
  5426.           xmin%=ScrapBlk%!8
  5427.            xmax%=ScrapBlk%!16
  5428.            ymin%=ScrapBlk%!12
  5429.            ymax%=ScrapBlk%!20
  5430.           showicondata%=
  5431.         
  5432.         
  5433.  showicondata% 
  5434.       xmin$=
  5435. (xmin%)
  5436.       xmax$=
  5437. (xmax%)
  5438.       ymin$=
  5439. (ymin%)
  5440.       ymax$=
  5441. (ymax%)
  5442. .      s$=
  5443. (xmax%-xmin%)+"x"+
  5444. (ymax%-ymin%)
  5445.         
  5446.  t$<>$(IconText%(7)) 
  5447. seticontext(7,t$)
  5448.  i$<>$(IconText%(8)) 
  5449. seticontext(8,i$)
  5450.  xmin$<>$(IconText%(9)) 
  5451. seticontext(9,xmin$)
  5452.  xmax$<>$(IconText%(26)) 
  5453. seticontext(26,xmax$)
  5454.  ymin$<>$(IconText%(10)) 
  5455. seticontext(10,ymin$)
  5456.  ymax$<>$(IconText%(27)) 
  5457. seticontext(27,ymax$)
  5458.  s$<>$(IconText%(11)) 
  5459. seticontext(11,s$)
  5460.  m$<>$(IconText%(24)) 
  5461. seticontext(24,m$)
  5462. alignicons(window%)
  5463.  move%,imask%,type%,i%,anchorx%,anchory%
  5464.  dx1%,dx2%,dy1%,dy2%,handle%
  5465. "move%=
  5466. iconselected(AlignW%,8)
  5467. imask%=(31<<16)+(1<<21)
  5468.  "Wimp_WhichIcon",AlignW%,SelBlk%,imask%,(1<<16)+(1<<21)
  5469. type%=SelBlk%!0
  5470. sel_get(window%)
  5471.  NrSelected%>1 
  5472.  type% 
  5473. .    
  5474.  2,3 : 
  5475. sel_sort(window%,0,0,1,0,1,1)
  5476. .    
  5477.  4   : 
  5478. sel_sort(window%,0,1,0,0,1,1)
  5479. .    
  5480.  5,6 : 
  5481. sel_sort(window%,1,1,0,1,0,0)
  5482. .    
  5483.  7   : 
  5484. sel_sort(window%,1,0,1,1,1,1)
  5485.   IconBlk%!0=window%
  5486.   IconBlk%!4=SelBlk%!0
  5487.  "Wimp_GetIconState",,IconBlk%
  5488.  type% 
  5489.     E      anchorx%=IconBlk%!8                                : 
  5490.  left
  5491. G      anchorx%=IconBlk%!8+(IconBlk%!16-IconBlk%!8)
  5492. 2   : 
  5493.  h centre
  5494. F      anchorx%=IconBlk%!16                               : 
  5495.  right
  5496. D      anchory%=IconBlk%!20                               : 
  5497. G      anchory%=IconBlk%!12+(IconBlk%!20-IconBlk%!12)
  5498.  v centre
  5499. G      anchory%=IconBlk%!12                               : 
  5500.  bottom
  5501.  i%=1 
  5502.  NrSelected%-1
  5503.     IconBlk%!0=window%
  5504. !    IconBlk%!4=SelBlk%!(4*i%)
  5505. (    
  5506.  "Wimp_GetIconState",,IconBlk%
  5507.     dx1%=0
  5508.     dx2%=0
  5509.     dy1%=0
  5510.     dy2%=0
  5511.  type% 
  5512.       
  5513. $        dx1%=anchorx%-IconBlk%!8
  5514.         
  5515.  move% 
  5516.  dx2%=dx1%
  5517.       
  5518. "A        dx1%=anchorx%-(IconBlk%!8+(IconBlk%!16-IconBlk%!8)
  5519.         
  5520.  move% 
  5521.  dx2%=dx1%
  5522.       
  5523. %%        dx2%=anchorx%-IconBlk%!16
  5524.         
  5525.  move% 
  5526.  dx1%=dx2%
  5527.       
  5528. (%        dy2%=anchory%-IconBlk%!20
  5529.         
  5530.  move% 
  5531.  dy1%=dy2%
  5532.       
  5533. +C        dy1%=anchory%-(IconBlk%!12+(IconBlk%!20-IconBlk%!12)
  5534.         
  5535.  move% 
  5536.  dy2%=dy1%
  5537.       
  5538. .%        dy1%=anchory%-IconBlk%!12
  5539.         
  5540.  move% 
  5541.  dy2%=dy1%
  5542. 0        
  5543. 1"    IconBlk%!8=IconBlk%!8+dx1%
  5544. 2$    IconBlk%!12=IconBlk%!12+dy1%
  5545. 3$    IconBlk%!16=IconBlk%!16+dx2%
  5546. 4$    IconBlk%!20=IconBlk%!20+dy2%
  5547. 5=    
  5548.  IconBlk%!16<=IconBlk%!8 
  5549.  IconBlk%!16=IconBlk%!8+32
  5550. 6?    
  5551.  IconBlk%!20<=IconBlk%!12 
  5552.  IconBlk%!20=IconBlk%!12+32
  5553. 7>    handle%=
  5554. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5555.  --- shade the appropriate icons in the Align window
  5556. align_shadeicons
  5557. iconselected(AlignW%,3) 
  5558. iconselected(AlignW%,6) 
  5559. shadeicon(AlignW%,9,1)
  5560. shadeicon(AlignW%,9,0)
  5561. shadeicon(AlignW%,3,
  5562. iconselected(AlignW%,9))
  5563. shadeicon(AlignW%,6,
  5564. iconselected(AlignW%,9))
  5565. spaceicons(window%)
  5566.  imask%,type%,i%,distance%,space%,ib%,anchor%,dx%,dy%,handle%
  5567. I'SpaceOut_Space%=
  5568. ($(IconText%(18)))
  5569. JOimask%=(31<<16)+(1<<21) : 
  5570.  check if spacing must be horizontal or vertical
  5571.  "Wimp_WhichIcon",SpaceW%,SelBlk%,imask%,(1<<16)+(1<<21)
  5572. LBtype%=SelBlk%!0 : 
  5573.  type%=2 => horizontal, type%=3 => vertical
  5574. sel_get(window%)
  5575.  NrSelected%>1 
  5576.  type%=2 
  5577. P&    
  5578. sel_sort(window%,0,0,1,0,1,0)
  5579. R&    
  5580. sel_sort(window%,1,0,1,1,1,0)
  5581. iconselected(SpaceW%,4) 
  5582. U!    distance%=SpaceOut_Space%
  5583. W,    
  5584.  calc available space between icons
  5585.     WinBlk%!0=window%
  5586. Y(    
  5587.  "Wimp_GetWindowInfo",,WinBlk%
  5588. Z.    
  5589.  start with space between outer icons
  5590.  type%=2 
  5591. \>      space%=WinBlk%!(92+32*(SelBlk%!(4*(NrSelected%-1))))
  5592. ]/      space%-=WinBlk%!(92+32*(SelBlk%!0)+8)
  5593. ^        
  5594. _@      space%=WinBlk%!(92+32*(SelBlk%!(4*(NrSelected%-1)))+4)
  5595. `0      space%-=WinBlk%!(92+32*(SelBlk%!0)+12)
  5596. a        
  5597. b.    
  5598.  subtract sizes of intermediate icons
  5599.  NrSelected%>2 
  5600. d"      
  5601.  i%=1 
  5602.  (NrSelected%-2)
  5603. e.        ib%=WinBlk%+92+32*(SelBlk%!(4*i%))
  5604.         
  5605.  type%=2 
  5606. g#          space%-=(ib%!8-ib%!0)
  5607.         
  5608. i$          space%-=(ib%!12-ib%!4)
  5609.         
  5610.       
  5611. l        
  5612. m*    distance%=space% 
  5613.  (NrSelected%-1)
  5614. n4    NrSelected%-=1 : 
  5615.  to avoid moving last icon
  5616.   IconBlk%!0=window%
  5617.   IconBlk%!4=SelBlk%!0
  5618.  "Wimp_GetIconState",,IconBlk%
  5619.  type% 
  5620. t!    
  5621.  2 : anchor%=IconBlk%!16
  5622. u!    
  5623.  3 : anchor%=IconBlk%!20
  5624.  i%=1 
  5625.  NrSelected%-1
  5626.     anchor%+=distance%
  5627.     IconBlk%!0=window%
  5628. z!    IconBlk%!4=SelBlk%!(4*i%)
  5629. {(    
  5630.  "Wimp_GetIconState",,IconBlk%
  5631.     dx%=0
  5632.     dy%=0
  5633.  type% 
  5634. &      
  5635.  2 : dx%=anchor%-IconBlk%!8
  5636. '      
  5637.  3 : dy%=anchor%-IconBlk%!12
  5638.         
  5639. !    IconBlk%!8=IconBlk%!8+dx%
  5640. #    IconBlk%!12=IconBlk%!12+dy%
  5641. #    IconBlk%!16=IconBlk%!16+dx%
  5642. #    IconBlk%!20=IconBlk%!20+dy%
  5643.  type% 
  5644. #      
  5645.  2 : anchor%=IconBlk%!16
  5646. #      
  5647.  3 : anchor%=IconBlk%!20
  5648.         
  5649. >    handle%=
  5650. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5651. space_shadeicons
  5652.  useavail%,i%
  5653. &useavail%=
  5654. iconselected(SpaceW%,8)
  5655.  i%=5 
  5656. shadeicon(SpaceW%,i%,useavail%)
  5657. frameicons(window%)
  5658.  i%,j%,xmin%,ymin%,xmax%,ymax%,handle%,h%,w%
  5659. %Frame_IconNo%=
  5660. ($(IconText%(32)))
  5661. $Frame_Space%=
  5662. ($(IconText%(33)))
  5663. &Frame_LabelNo%=
  5664. ($(IconText%(34)))
  5665. (Frame_LeftSpace%=
  5666. ($(IconText%(35)))
  5667. iconselected(FrameW%,5) 
  5668.  Frame_IconNo%=-1
  5669. iconselected(FrameW%,15) 
  5670.  Frame_LabelNo%=-1
  5671. sel_get(window%)
  5672.  remove frame and label icon# from selection block
  5673.  i%=0 
  5674.  NrSelected%-1
  5675.   icon%=SelBlk%!(4*i%)
  5676.   SelBlk%!(4*j%)=icon%
  5677.  (icon%<>Frame_IconNo%) 
  5678.  (icon%<>Frame_LabelNo%) 
  5679.  j%+=1
  5680.  j%=0 
  5681. dialogue(10,"")
  5682. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5683. xmin%-=Frame_Space%
  5684. ymin%-=Frame_Space%
  5685. xmax%+=Frame_Space%
  5686. ymax%+=Frame_Space%
  5687.  Frame_IconNo%=-1 
  5688.  re-open window "around" icons
  5689.   WinBlk%!0=window%
  5690.  "Wimp_GetWindowState",,WinBlk%
  5691. (  WinBlk%!8=WinBlk%!16-(ymax%-ymin%)
  5692. (  WinBlk%!12=WinBlk%!4+(xmax%-xmin%)
  5693.   WinBlk%!20=xmin%
  5694.   WinBlk%!24=ymax%
  5695.  "Wimp_OpenWindow",,WinBlk%
  5696.  redefine frame icon
  5697.   IconBlk%!0=window%
  5698.   IconBlk%!4=Frame_IconNo%
  5699.  "Wimp_GetIconState",,IconBlk%
  5700.  Frame_LabelNo%<>-1 
  5701.     ScrapBlk%!0=window%
  5702. "    ScrapBlk%!4=Frame_LabelNo%
  5703. )    
  5704.  "Wimp_GetIconState",,ScrapBlk%
  5705. %    w%=(ScrapBlk%!16-ScrapBlk%!8)
  5706. &    h%=(ScrapBlk%!20-ScrapBlk%!12)
  5707.     h%=0
  5708.   IconBlk%!8=xmin%
  5709. )  IconBlk%!12=ymin%                  
  5710. )  IconBlk%!16=xmax%                  
  5711.    IconBlk%!20=ymax%+(h% 
  5712. ;  handle%=
  5713. redefineicon(window%,Frame_IconNo%,IconBlk%)
  5714.  Frame_LabelNo%<>-1 
  5715.  redefine label icon
  5716.     IconBlk%!0=window%
  5717. !    IconBlk%!4=Frame_LabelNo%
  5718. (    
  5719.  "Wimp_GetIconState",,IconBlk%
  5720. %    
  5721. iconselected(FrameW%,20) 
  5722.       
  5723.  centered label
  5724. )      IconBlk%!8=(xmin%+xmax%-w%) 
  5725.         
  5726.       
  5727.  left-spaced label
  5728. +      IconBlk%!8=xmin%+Frame_LeftSpace%
  5729.                   
  5730.     IconBlk%!12=ymax%
  5731. !    IconBlk%!16=IconBlk%!8+w%
  5732. "    IconBlk%!20=IconBlk%!12+h%
  5733. >    handle%=
  5734. redefineicon(window%,Frame_LabelNo%,IconBlk%)
  5735. frame_fillwin
  5736. Frame_IconNo%=SelBlk%!0
  5737. seticontext(32,
  5738. (Frame_IconNo%))
  5739. Frame_LabelNo%=SelBlk%!4
  5740. seticontext(34,
  5741. (Frame_LabelNo%))
  5742. frame_shadeicons
  5743. frame_shadeicons
  5744.  f1%,f2%,f3%,i%
  5745.  f1%=
  5746. iconselected(FrameW%,5)
  5747. 'f2%=f1% 
  5748. iconselected(FrameW%,15)
  5749. 'f3%=f2% 
  5750. iconselected(FrameW%,20)
  5751.  i%=7 
  5752. shadeicon(FrameW%,i%,f1%)
  5753. shadeicon(FrameW%,15,f1%)
  5754. shadeicon(FrameW%,16,f1%)
  5755.  i%=17 
  5756. shadeicon(FrameW%,i%,f2%)
  5757.  i%=22 
  5758. shadeicon(FrameW%,i%,f3%)
  5759. tidyicons(window%,action%)
  5760.  changed%,xmin%,xmax%,ymin%,ymax%,copy%
  5761.  ib1%,ib2%,end%,nricons%,dx%,dy%,i%,handle%
  5762. WinBlk%!0=window%
  5763.  "Wimp_GetWindowInfo",,WinBlk%
  5764. changed%=0
  5765.  action%=2 
  5766.   xmin%=WinBlk%!20
  5767.   ymax%=WinBlk%!24
  5768. (  xmax%=xmin%+(WinBlk%!12-WinBlk%!4)
  5769. (  ymin%=ymax%-(WinBlk%!16-WinBlk%!8)
  5770.   xmin%=WinBlk%!44
  5771.   ymin%=WinBlk%!48
  5772.   xmax%=WinBlk%!52
  5773.   ymax%=WinBlk%!56
  5774.  WinBlk%!88>0 
  5775.   ib1%=WinBlk%+92
  5776.   ib2%=ib1%
  5777.   end%=ib1%+32*(WinBlk%!88)
  5778.   nricons%=0
  5779.  ib1%<end%
  5780.     copy%=
  5781. (    
  5782.  change icon coords if required
  5783.     dx%=0
  5784.     dy%=0
  5785.  action% 
  5786.       
  5787. %        
  5788.  ((ib1%!16)
  5789. (1<<23))=0 
  5790. 9          
  5791.  test if icon position is within work area
  5792. /          
  5793.  ib1%!0<xmin% 
  5794.  dx%=xmin%-ib1%!0
  5795. /          
  5796.  ib1%!4<ymin% 
  5797.  dy%=ymin%-ib1%!4
  5798. /          
  5799.  ib1%!8>xmax% 
  5800.  dx%=xmax%-ib1%!8
  5801. 1          
  5802.  ib1%!12>ymax% 
  5803.  dy%=ymax%-ib1%!12
  5804. /          
  5805.  (dx%<>0)
  5806. (dy%<>0) 
  5807.  changed%+=1
  5808.         
  5809.       
  5810.  #        
  5811.  ((ib1%!16)
  5812. (1<<23)) 
  5813. !C          ib1%!16=(ib1%!16) 
  5814. (1<<23) : 
  5815.  reset "deleted" flag
  5816. "$          
  5817.  (ib1%!16) 
  5818.  (1<<8) 
  5819. #B            
  5820.  can't retrieve indirected data - fill in default
  5821. $*            ib1%!20=
  5822. heap_get(ib1%!28)
  5823.             $(ib1%!20)=""
  5824. &&            
  5825.  (ib1%!16) 
  5826.  (1<<0) 
  5827.               ib1%!24=-1
  5828.             
  5829. )$              ib1%!24=WinBlk%!68
  5830.             
  5831.           
  5832.           
  5833.  action%=4 
  5834.             dx%=-100000
  5835.             dy%=-100000
  5836.           
  5837.           changed%+=1
  5838.         
  5839.       
  5840. 3#        
  5841.  ((ib1%!16)
  5842. (1<<23)) 
  5843. 48          copy%=
  5844.  purge - do not copy data block
  5845.           changed%+=1
  5846.         
  5847. 7        
  5848.  copy% 
  5849.       ib1%!0=ib1%!0+dx%
  5850.       ib1%!4=ib1%!4+dy%
  5851.       ib1%!8=ib1%!8+dx%
  5852.       ib1%!12=ib1%!12+dy%
  5853. =?      
  5854.  move icon data to new position in window data block
  5855.       
  5856.  i%=0 
  5857.         ib2%!i%=ib1%!i%
  5858.       
  5859.       ib2%+=32
  5860.       nricons%+=1
  5861. C        
  5862.     ib1%+=32
  5863.  changed%=0 
  5864. dialogue(6,"")
  5865.     WinBlk%!88=nricons%
  5866. J*    handle%=
  5867. redefinewindow(WinBlk%,1)
  5868. K     
  5869. dialogue(7,
  5870. (changed%))
  5871. =handle%
  5872. setworkarea
  5873.  xtopleft%,ytopleft%,xsize%,ysize%,xmin%,ymin%
  5874. WinBlk%!0=LastMenu_Win%
  5875.  "Wimp_GetWindowInfo",,WinBlk%
  5876. T!xtopleft%=
  5877. ($(IconText%(12)))
  5878. U!ytopleft%=
  5879. ($(IconText%(13)))
  5880. xsize%=
  5881. ($(IconText%(14)))
  5882. ysize%=
  5883. ($(IconText%(15)))
  5884. X%xmin%=
  5885. ($(IconText%(16))) 
  5886.  &FFFF
  5887. Y%ymin%=
  5888. ($(IconText%(17))) 
  5889.  &FFFF
  5890.  (xsize%<32) 
  5891.  (ysize%<32) 
  5892. complain(
  5893. msg_lookup0("IWAS"))
  5894.  xmin%>xsize% 
  5895.     xmin%=xsize%
  5896. _!    
  5897. seticontext(16,
  5898. (xmin%))
  5899.  ymin%>ysize% 
  5900.     ymin%=ysize%
  5901. c!    
  5902. seticontext(17,
  5903. (ymin%))
  5904.   WinBlk%!44=xtopleft%
  5905. f!  WinBlk%!48=ytopleft%-ysize%
  5906. g!  WinBlk%!52=xtopleft%+xsize%
  5907.   WinBlk%!56=ytopleft%
  5908. i"  WinBlk%!72=(ymin%<<16)+xmin%
  5909. j.  LastMenu_Win%=
  5910. redefinewindow(WinBlk%,1)
  5911. centericonsel(window%,default%,dim%)
  5912.  xmin%,ymin%,xmax%,ymax%,xfree%,yfree%,dx%,dy%,i%,handle%
  5913. sel_get(window%)
  5914.  (NrSelected%=0) 
  5915.  (default%>=0) 
  5916.   SelBlk%!0=default%
  5917.   NrSelected%=1
  5918.  NrSelected%>0 
  5919. sel_box(window%,xmin%,ymin%,xmax%,ymax%)
  5920.   ScrapBlk%!0=window%
  5921.  "Wimp_GetWindowState",,ScrapBlk%
  5922. y5  xfree%=(ScrapBlk%!12-ScrapBlk%!4)-(xmax%-xmin%)
  5923. z)  dx%=ScrapBlk%!20+(xfree% 
  5924.  2)-xmin%
  5925. {5  yfree%=(ScrapBlk%!16-ScrapBlk%!8)-(ymax%-ymin%)
  5926. |)  dy%=ScrapBlk%!24-(yfree% 
  5927.  2)-ymax%
  5928.  dim%=2 
  5929.  dx%=0
  5930.  dim%=1 
  5931.  dy%=0
  5932.  i%=0 
  5933.  NrSelected%-1
  5934.     IconBlk%!0=window%
  5935. !    IconBlk%!4=SelBlk%!(4*i%)
  5936. (    
  5937.  "Wimp_GetIconState",,IconBlk%
  5938. !    IconBlk%!8=IconBlk%!8+dx%
  5939. #    IconBlk%!12=IconBlk%!12+dy%
  5940. #    IconBlk%!16=IconBlk%!16+dx%
  5941. #    IconBlk%!20=IconBlk%!20+dy%
  5942. >    handle%=
  5943. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  5944.  --- support one of the Wimp extension modules ---
  5945.  type%=0 -> none
  5946.  type%=1 -> Interface
  5947.  type%=2 -> AEH module
  5948.  type%=3 -> WimpExt
  5949. support(type%)
  5950.  old%,flg%,mod$,module$
  5951. old%=Support%
  5952. Support%=type%
  5953.  type% 
  5954.  1 : mod$="Interface" : module$="InterfaceManager"
  5955.  2 : mod$="AEH"       : module$="AEHmodule"
  5956.  3 : mod$="WimpExt"   : module$="WimpExtension"
  5957.  type%<>0 
  5958. modulepresent(module$) 
  5959.     Support%=old%
  5960. dialogue(3,mod$)
  5961.  Support%<>old% 
  5962.  deregister previously selected module
  5963.  old% 
  5964.       
  5965.  "XAEH_Register",-1
  5966. +      
  5967.  "XWimpExt_CloseDown",ThisTask%
  5968.  register newly selected module
  5969.  type% 
  5970.       
  5971.  "XAEH_Register",1
  5972. @      
  5973.  "XWimpExt_Initialise",16,ThisTask%,1+(1<<8)+(1<<10)
  5974. redrawall
  5975. selecticon(OptPaneW%,9,Support%=1)
  5976. selecticon(OptPaneW%,10,Support%=2)
  5977. selecticon(OptPaneW%,34,Support%=3)
  5978.  --- check the presence of a relocatable module ---
  5979. modulepresent(rm$)
  5980.  flg%
  5981.  "XOS_Module",18,rm$ 
  5982.  ;flg%
  5983. =(flg% 
  5984.  1)=0
  5985.  --- force the redraw of all open template windows ---
  5986. redrawall
  5987.  NrTemplates%>0 
  5988.  i%=0 
  5989.  (NrTemplates%-1)
  5990. "    Blk%!0=TemplHandle%!(4*i%)
  5991. &    
  5992.  "Wimp_GetWindowState",,Blk%
  5993.  (Blk%!32 
  5994.  (1<<16)) 
  5995. @      
  5996.  "Wimp_ForceRedraw",-1,Blk%!4,Blk%!8,Blk%!12,Blk%!16
  5997.         
  5998. setmainfname(fn$)
  5999. MainFname$=fn$
  6000.  ChangesMade% 
  6001.  fn$+=" *"
  6002. settitlebar(TemplW%,TemplTbar%,fn$)
  6003.  --- set the 'changes made' status ---
  6004. setchanged(switch%)
  6005.  title$
  6006.  ChangesMade%<>switch% 
  6007.  switch% 
  6008. !    title$=$(TemplTbar%)+" *"
  6009. 1    title$=
  6010. $(TemplTbar%),
  6011. ($(TemplTbar%))-2)
  6012. settitlebar(TemplW%,TemplTbar%,title$)
  6013.   ChangesMade%=switch%
  6014.  --- build string with info to send to !Help ---
  6015. iconhelp(no%,icon%)
  6016.  help$,p%
  6017. ,help$="Template '"+$(TemplNames%+28*no%)
  6018.  icon%>=0 
  6019. &  help$+="', Icon #"+
  6020. (icon%)+"|M"
  6021. &  ScrapBlk%!0=TemplHandle%!(4*no%)
  6022.   ScrapBlk%!4=icon%
  6023.  "Wimp_GetIconState",,ScrapBlk%
  6024.   flags%=ScrapBlk%!24
  6025.  (flags% 
  6026. +    
  6027.  0 : help$+="Non-text, non-sprite"
  6028.  1 : help$+="Text"
  6029.  2 : help$+="Sprite"
  6030. $    
  6031.  3 : help$+="Text + Sprite"
  6032.   help$+=" icon, "
  6033.  (flags% 
  6034.  &100) 
  6035. =    help$+="Indirected (max. size "+
  6036. (ScrapBlk%!36)+")|M"
  6037.  (flags% 
  6038.       
  6039.  ScrapBlk%!32=-1 
  6040. )        help$+="No validation string"
  6041.       
  6042. =        help$+="Validation string: '"+$(ScrapBlk%!32)+"'"
  6043.       
  6044.         
  6045. "    help$+="Non-indirected|M "
  6046. B  help$+="|MButton type: '"+$(IcButton%+20*((flags%>>12)
  6047.  &F))
  6048. ,  help$+="', ESG: "+
  6049. ((flags%>>16)
  6050.  &1F)
  6051.  OSversion%>=300 
  6052. J    
  6053.  replace "\" with "\\", else !Help (RiscOS 3) thinks it's a token
  6054.     p%=
  6055. help$,"\")
  6056.  p%<>0
  6057. +      help$=
  6058. help$,p%)+"\"+
  6059. help$,p%+1)
  6060.       p%=
  6061. help$,"\",p%+2)
  6062.         
  6063. $  WinBlk%!0=TemplHandle%!(4*no%)
  6064.  "Wimp_GetWindowInfo",,WinBlk%
  6065. 3  help$+="', Window background|MButton type: '"
  6066.     :  help$+=$(WinButton%+20*(((WinBlk%!64)>>12)
  6067.  &F))+"'"
  6068. =help$
  6069.  --- schedule the closedown of TemplEd ---
  6070. prequit
  6071. PollMask%=PollMask% 
  6072. Quit%=
  6073.  --- send help-request to StrongHelp, for help on a subject ---
  6074. askhelp(string$)
  6075. Blk%!0=256
  6076. Blk%!12=0
  6077. Blk%!16=&43B00
  6078. &$(Blk%+20)="Help_Word "+string$+
  6079.  "Wimp_SendMessage",17,Blk%,0
  6080.  *** procs for saving templates ***
  6081. savetemplates(fname$)
  6082.  handle%,offset%,no%
  6083. fname$,".")=0) 
  6084.  (fname$<>"<Wimp$Scrap>") 
  6085. complain(
  6086. msg_lookup0("ISLF"))
  6087.  "Hourglass_On"
  6088. save_init(fname$,NrTemplates%,handle%,offset%)
  6089.  #handle% : 
  6090. error(0) : 
  6091.  no%=0 
  6092.  NrTemplates%-1
  6093. (?    
  6094.  SavingSelection%) 
  6095. iconselected(TemplW%,no%)) 
  6096. )-      
  6097. save_template(no%,handle%,offset%)
  6098. *        
  6099. save_finish(handle%,offset%)
  6100.  "OS_File",18,fname$,&FEC
  6101.  "Hourglass_Off"
  6102.  fname$=MainFname$ 
  6103. setchanged(
  6104.  QuitAfterSave% 
  6105. prequit
  6106. save_init(fname$,nrtempl%,
  6107.  handle%,
  6108.  offset%)
  6109. Save_IndexOfs%=16
  6110.  i%=0 
  6111.  FileIndexSize%-1
  6112.   FileIndex%?i%=0
  6113.  set up translation table for font handles -> internal font handles
  6114.  i%=0 
  6115.   Fra%?i%=0
  6116. Save_NrFonts%=0
  6117. ?2FileIndex%!0=-1          : 
  6118.  no fonts (so far)
  6119. @Loffset%=16+nrtempl%*24+4 : 
  6120.  skip first part of file (index saved later)
  6121. handle%=
  6122.  fname$
  6123. save_template(no%,handle%,
  6124.  offset%)
  6125.  nricons%,i%,dataofs%,ib%
  6126. F'FileIndex%!(Save_IndexOfs%)=offset%
  6127. G#FileIndex%!(Save_IndexOfs%+8)=1
  6128. H9$(FileIndex%+Save_IndexOfs%+12)=$(TemplNames%+28*no%)
  6129. I"WinBlk%!0=TemplHandle%!(4*no%)
  6130.  "Wimp_GetWindowInfo",,WinBlk%
  6131.  PaneFlag%?no% 
  6132. L<  WinBlk%!32=WinBlk%!32 
  6133.  (1<<5) : 
  6134.  restore 'Pane' flag
  6135. nricons%=WinBlk%!88
  6136. dataofs%=88+32*nricons%
  6137. P6WinBlk%!68=1 : 
  6138.  reset sprite pointer to Wimp area
  6139. save_translate(WinBlk%+60,WinBlk%+76,dataofs%)
  6140.  nricons%>0 
  6141.  i%=0 
  6142.  nricons%-1
  6143.     ib%=WinBlk%+92+i%*32
  6144. U/    
  6145. save_translate(ib%+16,ib%+20,dataofs%)
  6146.  Save_Unselected% 
  6147. W$      ib%!16=ib%!16 
  6148. (1<<21))
  6149. X        
  6150.  "OS_GBPB",1,handle%,WinBlk%+4,88+32*nricons%,offset% 
  6151.  ,,,,offset%
  6152.  "Wimp_GetWindowInfo",,WinBlk%
  6153. save_icon(WinBlk%!(60),WinBlk%+76,handle%,offset%)
  6154.  nricons%>0 
  6155.  i%=0 
  6156.  nricons%-1
  6157. `M    
  6158. save_icon(WinBlk%!(92+i%*32+16),WinBlk%+92+i%*32+20,handle%,offset%)
  6159. cEFileIndex%!(Save_IndexOfs%+4)=offset%-FileIndex%!(Save_IndexOfs%)
  6160. Save_IndexOfs%+=24
  6161.  --- translate data in icon block (indirected pointers + font handles) ---
  6162. save_translate(flagptr%,data%,
  6163.  dataofs%)
  6164.  flags%,sl%,fhandle%,inthandle%
  6165. flags%=flagptr%!0
  6166.  (flags% 
  6167.  (1<<23))>0 
  6168.  icon has been deleted - fill with default data
  6169.   flagptr%!0=&07800001
  6170.   $(data%)="<Deleted>"
  6171.  1. calculate file offset for indirected icon data
  6172.  (flags% 
  6173.  &100)=&100 
  6174.  (flags% 
  6175.       
  6176. tL        data%!0=dataofs%   : 
  6177.  default data for non-text,non-sprite icon
  6178. uE        dataofs%+=1        : 
  6179.  empty string, 1 char is terminator
  6180.         data%!4=-1
  6181.       
  6182.         sl%=
  6183. ($(data%!0))
  6184.         data%!0=dataofs%
  6185.         dataofs%+=sl%+1
  6186. {D        data%!4=1          : 
  6187.  reset sprite pointer to Wimp area
  6188.       
  6189.         sl%=
  6190. ($(data%!0))
  6191.         data%!0=dataofs%
  6192.         dataofs%+=sl%+1
  6193.         
  6194.  data%!4<>-1 
  6195.           sl%=
  6196. ($(data%!4))
  6197.           data%!4=dataofs%
  6198.           dataofs%+=sl%+1
  6199.         
  6200.         
  6201.  2. translate font handle to internal handle
  6202.  flags% 
  6203.  (1<<6) 
  6204.     fhandle%=flags%>>24
  6205.      inthandle%=Fra%?fhandle%
  6206.  inthandle%=0 
  6207.       Save_NrFonts%+=1
  6208. "      inthandle%=Save_NrFonts%
  6209. "      Fra%?fhandle%=inthandle%
  6210.         
  6211. 8    flagptr%!0=(flags% 
  6212.  &FFFFFF) 
  6213.  (inthandle%<<24)
  6214.  --- save indirected icon data to file ---
  6215. save_icon(flags%,data%,handle%,
  6216.  offset%)
  6217. 8ScrapBlk%!0=13 : 
  6218.  temporary buffer for empty string
  6219.  (flags% 
  6220.  &800100)=&100 
  6221.  flags% 
  6222.     sl%=
  6223. ($(data%!0))
  6224. B    
  6225.  "OS_GBPB",1,handle%,data%!0,sl%+1,offset% 
  6226.  ,,,,offset%
  6227.  flags% 
  6228.       
  6229.  data%!4<>-1 
  6230.         sl%=
  6231. ($(data%!4))
  6232. F        
  6233.  "OS_GBPB",1,handle%,data%!4,sl%+1,offset% 
  6234.  ,,,,offset%
  6235.       
  6236.         
  6237. 7    
  6238.  non-text,non-sprite icon - write empty string
  6239. @    
  6240.  "OS_GBPB",1,handle%,ScrapBlk%,1,offset% 
  6241.  ,,,,offset%
  6242. save_finish(handle%,offset%)
  6243.  i%,j%
  6244.  save font data
  6245.  Save_NrFonts%>0 
  6246.   FileIndex%!0=offset%
  6247.  i%=1 
  6248.  Save_NrFonts%
  6249. /    
  6250.  find font that got internal handle i%
  6251.     j%=0
  6252.  Fra%?j%<>i%
  6253.       j%+=1
  6254.         
  6255. E    
  6256.  "Font_ReadDefn",j%,FontData%+8 
  6257.  ,,FontData%!0,FontData%!4
  6258. A    
  6259.  "OS_GBPB",1,handle%,FontData%,48,offset% 
  6260.  ,,,,offset%
  6261.  save header + index entries
  6262.  "OS_GBPB",1,handle%,FileIndex%,Save_IndexOfs%+4,0
  6263.  #handle%
  6264.  *** procs for loading and deleting user templates ***
  6265. templ_add(name$,wblk%,setextent%)
  6266.  no%,nameptr%,spptr%,i%
  6267.  NrTemplates%=MaxTemplates% 
  6268. complain(
  6269. msg_lookup0("MTPX"))
  6270.   no%=NrTemplates%
  6271. '  PaneFlag%?no%=(wblk%!32) 
  6272.  (1<<5)
  6273. #  wblk%!32=(wblk%!32) 
  6274. (1<<5)
  6275.  "Wimp_CreateWindow",,wblk%+4 
  6276.  TemplHandle%!(4*no%)
  6277.   NrTemplates%+=1
  6278.   ScrapBlk%!0=TemplW%
  6279. 6  ScrapBlk%!4=8+TemplW_IconX%*(no% 
  6280.  TemplW_Cols%)
  6281. C  ScrapBlk%!12=(ScrapBlk%!4)+(TemplW_IconX%-8)-16*(11-
  6282. (name$))
  6283. 8  ScrapBlk%!16=-8-TemplW_IconY%*(no% 
  6284.  TemplW_Cols%)
  6285. 2  ScrapBlk%!8=(ScrapBlk%!16)-(TemplW_IconY%-8)
  6286. $  ScrapBlk%!20=TemplW_IconFlags%
  6287. !  nameptr%=TemplNames%+28*no%
  6288.   $(nameptr%)=name$
  6289.   ScrapBlk%!24=nameptr%
  6290. "  spptr%=TemplNames%+28*no%+14
  6291. '  $(spptr%)=
  6292. windowicon(wblk%!32,0)
  6293.   ScrapBlk%!28=spptr%
  6294.   ScrapBlk%!32=16
  6295.  "Wimp_CreateIcon",,ScrapBlk%
  6296.  DuplNames% 
  6297.     i%=0
  6298. &    
  6299.  $(TemplNames%+28*i%)<>name$
  6300.       i%+=1
  6301.         
  6302. $    
  6303.  i%<no% 
  6304. templ_delete(i%)
  6305.  setextent% 
  6306. setextent
  6307. seticonstate0(TemplW%,NrTemplates%-1,0,0)
  6308. templ_deleteall
  6309.  "Hourglass_On"
  6310.  NrTemplates%>0 
  6311.  i%=NrTemplates%-1 
  6312. templ_delete(i%)
  6313. setmainfname("Templates")
  6314. setchanged(
  6315.  "Hourglass_Off"
  6316. templ_delete(no%)
  6317.  i%,j%,wasopen%,oldhandle%
  6318. #oldhandle%=TemplHandle%!(4*no%)
  6319. WinBlk%!0=oldhandle%
  6320.  "Wimp_GetWindowInfo",,WinBlk%
  6321. iconrelease(WinBlk%!60,WinBlk%+76)
  6322.  WinBlk%!88>0 
  6323.  i%=0 
  6324.  (WinBlk%!88-1)
  6325. ?    
  6326. iconrelease(WinBlk%!(92+i%*32+16),WinBlk%+92+i%*32+20)
  6327.  "Wimp_DeleteWindow",,WinBlk%
  6328.  update browser window
  6329. WinBlk%!0=TemplW%
  6330.  "Wimp_GetWindowInfo",,WinBlk%
  6331. #wasopen%=(WinBlk%!32) 
  6332.  (1<<16)
  6333.  no%<(NrTemplates%-1) 
  6334.  move data for icons after the one that is deleted
  6335.  i%=no% 
  6336.  NrTemplates%-2
  6337.     ib%=WinBlk%+92+32*i%
  6338.  j%=0 
  6339.       ib%!j%=ib%!(j%+32)
  6340. 3    TemplHandle%!(4*i%)=TemplHandle%!(4*(i%+1))
  6341.     5    $(TemplNames%+28*i%)=$(TemplNames%+28*(i%+1))
  6342. ;    $(TemplNames%+28*i%+14)=$(TemplNames%+28*(i%+1)+14)
  6343. %    PaneFlag%?i%=PaneFlag%?(i%+1)
  6344. WinBlk%!88=WinBlk%!88-1
  6345.  "Wimp_DeleteWindow",,WinBlk%
  6346.  "Wimp_CreateWindow",,WinBlk%+4 
  6347.  TemplW%
  6348. NrTemplates%-=1
  6349. setchanged(NrTemplates%>0)
  6350. redefinebrowser(
  6351.  wasopen% 
  6352.   WinBlk%!0=TemplW%
  6353.  "Wimp_GetWindowInfo",,WinBlk%
  6354.  "Wimp_OpenWindow",,WinBlk%
  6355.  oldhandle%=IcEd_Win% 
  6356. closewindow(IcEdW%)
  6357.  oldhandle%=WinEd_Win% 
  6358. closewindow(WinEdW%)
  6359.  oldhandle%=LastMenu_Win% 
  6360.  LastMenu_Win%=-1
  6361.  NrTemplates%=0 
  6362. closewindow(StatW%)
  6363.  --- adapt extent of browser window to number of templates ---
  6364. setextent
  6365.  nrrows%,xsize%,titlesize%
  6366. "/nrrows%=1+((NrTemplates%-1) 
  6367.  TemplW_Cols%)
  6368.  nrrows%<2 
  6369.  nrrows%=2
  6370.  NrTemplates%=0 
  6371.   xsize%=8+TemplW_IconX%
  6372.  NrTemplates% < TemplW_MaxCol% 
  6373. (+    xsize%=8+NrTemplates%*TemplW_IconX%
  6374. *-    xsize%=8+TemplW_MaxCol%*TemplW_IconX%
  6375. -&titlesize%=128+16*
  6376. ($(TemplTbar%))
  6377.  xsize%<titlesize% 
  6378.  xsize%=titlesize%
  6379. ScrapBlk%!0=0
  6380. 0(ScrapBlk%!4=-8-TemplW_IconY%*nrrows%
  6381. ScrapBlk%!8=xsize%
  6382. ScrapBlk%!12=0
  6383.  "Wimp_SetExtent",TemplW%,ScrapBlk%
  6384.  --- move icons in browser window to adapt to new window size ---
  6385. redefinebrowser(reopen%)
  6386.  wasopen%,i%,ib%,xsize%,ysize%
  6387. WinBlk%!0=TemplW%
  6388.  "Wimp_GetWindowInfo",,WinBlk%
  6389. ;(wasopen%=((WinBlk%!32) 
  6390.  (1<<16))<>0
  6391.  WinBlk%!88>0 
  6392.  i%=0 
  6393.  (WinBlk%!88-1)
  6394.     ib%=WinBlk%+92+32*i%
  6395. ?@    xsize%=(TemplW_IconX%-8)-16*(11-
  6396. ($(TemplNames%+i%*28)))
  6397.     ysize%=ib%!12-ib%!4
  6398. A1    ib%!0=8+TemplW_IconX%*(i% 
  6399.  TemplW_Cols%)
  6400.     ib%!8=(ib%!0)+xsize%
  6401. C3    ib%!12=-8-TemplW_IconY%*(i% 
  6402.  TemplW_Cols%)
  6403.     ib%!4=(ib%!12)-ysize%
  6404.  "Wimp_DeleteWindow",,WinBlk%
  6405.  "Wimp_CreateWindow",,WinBlk%+4 
  6406.  TemplW%
  6407. setextent
  6408.  reopen% 
  6409.  wasopen% 
  6410.   WinBlk%!0=TemplW%
  6411.  "Wimp_GetWindowInfo",,WinBlk%
  6412.  adapt scroll offsets if visible area exceeds work area
  6413.  (WinBlk%!20+(WinBlk%!12-WinBlk%!4))>WinBlk%!52 
  6414. O4    WinBlk%!20=WinBlk%!52-(WinBlk%!12-WinBlk%!4)
  6415.  WinBlk%!20<0 
  6416. Q*      WinBlk%!12=WinBlk%!12+WinBlk%!20
  6417.       WinBlk%!20=0
  6418. S        
  6419.  (WinBlk%!24-(WinBlk%!16-WinBlk%!8))<WinBlk%!48 
  6420. V4    WinBlk%!24=WinBlk%!48+(WinBlk%!16-WinBlk%!8)
  6421.  WinBlk%!24>0 
  6422. X(      WinBlk%!8=WinBlk%!8+WinBlk%!24
  6423.       WinBlk%!20=0
  6424. Z        
  6425.  "Wimp_OpenWindow",,WinBlk%
  6426. templ_loadfile(fname$,loadsprites%)
  6427.  i%,nr%,name$,handle%,ip%,indirbuf%,sname$
  6428.  "Hourglass_On"
  6429.  "Hourglass_LEDs",1
  6430.  i%=0 
  6431.  FontUsage%(i%)>0 
  6432. fK    
  6433.  font in use - make for extra call to Font_LoseFont at end of proc
  6434.     Fra%?i%=1
  6435.     Fra%?i%=0
  6436.  NrTemplates%=0 
  6437.  fname$="<Wimp$Scrap>" 
  6438. n#    
  6439. setmainfname(NewLeafName$)
  6440. setmainfname(fname$)
  6441.  loadsprites% 
  6442. leafname(fname$)="Templates") 
  6443. t3  sname$=
  6444. dirname(fname$)+".Sprites"+SprSuffix$
  6445. fileexists(sname$) 
  6446. v     
  6447. loadusersprites(sname$)
  6448. x*    sname$=
  6449. dirname(fname$)+".Sprites"
  6450. y2    
  6451.  (SprSuffix$<>"") 
  6452. fileexists(sname$) 
  6453. z"      
  6454. loadusersprites(sname$)
  6455. {        
  6456. ~&indirbuf%=
  6457. heap_get(MaxIndirSize%)
  6458.  indirbuf%>0 
  6459.   handle%=
  6460.  fname$
  6461.  handle%>0 
  6462. F    
  6463.  read index of template file to check for oversized templates
  6464. :    
  6465.  "OS_GBPB",3,handle%,FileIndex%,FileIndexSize%,0
  6466.  #handle%
  6467. &    
  6468.  "Wimp_OpenTemplate",,fname$
  6469.     ip%=FileIndex%+24
  6470.     nr%=0
  6471.         
  6472. $      
  6473.  ip%!0>MaxTemplateSize% 
  6474. 5        
  6475. complain(
  6476. msg_lookup1("TTLB",$(ip%+12)))
  6477.       
  6478. :        
  6479. templ_load(nr%,name$,indirbuf%,MaxIndirSize%)
  6480.         
  6481.  nr%>0 
  6482. )          
  6483. templ_add(name$,WinBlk%,0)
  6484.         
  6485.       
  6486.       ip%+=24
  6487. 1    
  6488.  (nr%<=0) 
  6489.  (NrTemplates%=MaxTemplates%)
  6490.  "Wimp_CloseTemplate"
  6491. !    
  6492.  fname$="<Wimp$Scrap>" 
  6493. H      
  6494.  "OS_File",6,fname$ : 
  6495.  delete Wimp$Scrap file after reading
  6496.         
  6497.      
  6498. heap_release(indirbuf%)
  6499. setextent
  6500.  i%=0 
  6501.  neutralise calls of Font_FindFont done by Wimp_LoadTemplate
  6502.  Fra%?i%>1
  6503.  "Font_LoseFont",i%
  6504.     Fra%?i%-=1
  6505.  "Hourglass_Off"
  6506. openwindow(TemplW%,3)
  6507.  IcInfo_Active% 
  6508. openwindow(IcInfoW%,4)
  6509. templ_load(
  6510.  nr%,
  6511.  n$,p%,psize%)
  6512.  dx%,dy%,icon%,tb%,ib%
  6513.  "Wimp_CloseTemplate" : 
  6514. error(0) : nr%=0 : 
  6515. -n$="*"+
  6516. 0) : 
  6517.  name length must be 12
  6518.  "Wimp_LoadTemplate",,WinBlk%+4,p%,p%+psize%,Fra%,n$,nr% 
  6519.  ,,,,,n$,nr%
  6520.  nr%>0 
  6521.  make sure window origin position is within current screen size
  6522.   dx%=0
  6523.   dy%=0
  6524.  WinBlk%!4<0 
  6525.  dx%=-WinBlk%!4
  6526.  WinBlk%!8<0 
  6527.  dy%=-WinBlk%!8
  6528.  WinBlk%!12>ScreenSize_X% 
  6529.  dx%=ScreenSize_X%-WinBlk%!12
  6530.  WinBlk%!16>(ScreenSize_Y%-TBarHeight%) 
  6531. 0    dy%=ScreenSize_Y%-TBarHeight%-WinBlk%!16
  6532.   WinBlk%!4=WinBlk%!4+dx%
  6533.   WinBlk%!8=WinBlk%!8+dy%
  6534.   WinBlk%!12=WinBlk%!12+dx%
  6535.   WinBlk%!16=WinBlk%!16+dy%
  6536. ?  WinBlk%!68=UserSprites% : 
  6537.  set sprite area (CBP pointer)
  6538.  re-allocate indirected data, each field in a separate heap block
  6539.  WinBlk%!32 
  6540.  (1<<31) 
  6541.      tb%=WinBlk%!32 
  6542.  (1<<26)
  6543.     tb%=WinBlk%!32 
  6544.  (1<<0)
  6545.  tb% 
  6546. F    
  6547. iconrealloc(WinBlk%+60,WinBlk%+76) : 
  6548.  realloc title bar icon
  6549. ?    
  6550. icon_setspritearea(WinBlk%!60,WinBlk%+76,UserSprites%)
  6551. .    
  6552.  no title bar: fill data with default
  6553.     WinBlk%!60=&3D
  6554. "    $(WinBlk%+76)="<Untitled>"
  6555.  (WinBlk%!88)>0 
  6556. "    
  6557.  icon%=0 
  6558.  (WinBlk%!88)-1
  6559. !      ib%=WinBlk%+92+icon%*32
  6560. %      
  6561. iconrealloc(ib%+16,ib%+20)
  6562. >      
  6563.  set sprite pointers (indirected sprite-only icons)
  6564. 9      
  6565. icon_setspritearea(ib%!16,ib%+20,UserSprites%)
  6566.  icon%
  6567.  --- sort templates on names (case-insensitive) ---
  6568. templ_sort
  6569.  i%,j%,index%,candidate%,candname$,name$
  6570. ,i%=0 : 
  6571.  first <i%> templates are sorted
  6572.  i%<(NrTemplates%-1)
  6573.  find template with lowest name
  6574.   candidate%=i%
  6575. -  candname$=
  6576. upcase($(TemplNames%+i%*28))
  6577.  j%=i%+1 
  6578.  (NrTemplates%-1)
  6579. +    name$=
  6580. upcase($(TemplNames%+j%*28))
  6581.  name$<candname$ 
  6582.       candidate%=j%
  6583.       candname$=name$
  6584.         
  6585.  swap template data
  6586.  j%=0 
  6587.  (28-4) 
  6588. @    
  6589.  TemplNames%!(i%*28+j%),TemplNames%!(candidate%*28+j%)
  6590.  TemplHandle%!(4*i%),TemplHandle%!(4*candidate%)
  6591.  PaneFlag%?i%,PaneFlag%?candidate%
  6592.   i%+=1
  6593.  *** procs for reading and sorting selections ***
  6594.  --- get list of selected icons and count them ---
  6595. sel_get(window%)
  6596.  "Wimp_WhichIcon",window%,SelBlk%,(1<<21)+(1<<23),1<<21
  6597. NrSelected%=0
  6598.  SelBlk%!(4*NrSelected%)<>-1
  6599.   NrSelected%+=1
  6600.  --- select all icons ---
  6601. sel_all(window%)
  6602.  get all icons that are not selected nor deleted
  6603.  "Wimp_WhichIcon",window%,SelBlk%,(1<<21)+(1<<23),0
  6604.  SelBlk%!i%<>-1
  6605. selecticon(window%,SelBlk%!i%,1)
  6606.   i%+=4
  6607.  --- unselect all icons (except, maybe, for one icon) ---
  6608. sel_clear(window%,except%)
  6609.  "Wimp_WhichIcon",window%,SelBlk%,1<<21,1<<21
  6610.  SelBlk%!i%<>-1
  6611.  SelBlk%!i%<>except% 
  6612. selecticon(window%,SelBlk%!i%,0)
  6613.   i%+=4
  6614. NrSelected%=0
  6615.  --- sort icon selection (assumes selection present in SelBlk%) ---
  6616. sel_sort(window%,key1%,max1%,dir1%,key2%,max2%,dir2%)
  6617.  if key=0 then sort on horizontal coordinates, else vertical
  6618.  if max=0 then sort on minimum coordinates, else maximum
  6619.  if dir=0 then sort in descending order, else ascending
  6620.  i%,j%,index1%,index2%,ib%
  6621.  value1%,value2%,candidate%,bestsofar1%,bestsofar2%,better%
  6622. 5i%=0 : 
  6623.  first <i%> icons in selection are sorted
  6624.  key1%=0 
  6625.   index1%=0
  6626.   index1%=4
  6627.  max1% 
  6628.  index1%+=8
  6629.  key2%=0 
  6630.   index2%=0
  6631.   index2%=4
  6632.  max2% 
  6633.  index2%+=8
  6634. WinBlk%!0=window%
  6635.  "Wimp_GetWindowInfo",,WinBlk%
  6636.  i%<(NrSelected%-1)
  6637.  find icon with smallest/highest value for coordinate
  6638.   candidate%=i%
  6639. *(  ib%=WinBlk%+92+32*(SelBlk%!(4*i%))
  6640.   bestsofar1%=ib%!(index1%)
  6641.   bestsofar2%=ib%!(index2%)
  6642.  j%=i%+1 
  6643.  (NrSelected%-1)
  6644. .*    ib%=WinBlk%+92+32*(SelBlk%!(4*j%))
  6645.     value1%=ib%!(index1%)
  6646.     value2%=ib%!(index2%)
  6647.  bestsofar1%=value1% 
  6648. 2#      
  6649.  look at second sort key
  6650.       
  6651.  dir2% 
  6652. 4)        better%=(value2%<bestsofar2%)
  6653.       
  6654. 6)        better%=(value2%>bestsofar2%)
  6655.       
  6656. 8        
  6657.       
  6658.  dir1% 
  6659. :F        better%=(value1%<bestsofar1%) : 
  6660.  looking for lowest value
  6661.       
  6662. <G        better%=(value1%>bestsofar1%) : 
  6663.  looking for highest value
  6664.       
  6665. >        
  6666.  better% 
  6667.       candidate%=j%
  6668.       bestsofar1%=value1%
  6669.       bestsofar2%=value2%
  6670. C        
  6671.  swap icons in selection sequence
  6672.  SelBlk%!(4*candidate%),SelBlk%!(4*i%)
  6673.   i%+=1
  6674.  --- calculate coords of box surrounding selected icons ---
  6675. sel_box(window%,
  6676.  xmin%,
  6677.  ymin%,
  6678.  xmax%,
  6679.  ymax%)
  6680.  assume selection present in SelBlk%
  6681. ScrapBlk%!0=window%
  6682. ScrapBlk%!4=SelBlk%!0
  6683.  "Wimp_GetIconState",,ScrapBlk%
  6684. xmin%=ScrapBlk%!8
  6685. ymin%=ScrapBlk%!12
  6686. xmax%=ScrapBlk%!16
  6687. ymax%=ScrapBlk%!20
  6688.  i%=0 
  6689.  NrSelected%-1
  6690. W   ScrapBlk%!4=SelBlk%!(4*i%)
  6691.  "Wimp_GetIconState",,ScrapBlk%
  6692.  xmin%>ScrapBlk%!8 
  6693.  xmin%=ScrapBlk%!8
  6694.  ymin%>ScrapBlk%!12 
  6695.  ymin%=ScrapBlk%!12
  6696.  xmax%<ScrapBlk%!16 
  6697.  xmax%=ScrapBlk%!16
  6698.  ymax%<ScrapBlk%!20 
  6699.  ymax%=ScrapBlk%!20
  6700.  *** setup procs ***
  6701. setup_default
  6702. IcInfo_Active%=
  6703. DuplNames%=
  6704. Hatch%=
  6705. Setup_Support%=0
  6706. Grid_SizeLock%=
  6707. Grid_SizeX%=2
  6708. Grid_SizeY%=4
  6709. Grid_PosLock%=
  6710. Grid_PosX%=2
  6711. Grid_PosY%=4
  6712. Save_Unselected%=
  6713. DeleteOutside%=
  6714. TrapDclick%=
  6715. Stats_Decimal%=
  6716. IgnoreDeskFont%=
  6717. export_settype(2)
  6718. setup_load
  6719.  f%,etype%
  6720.  (ApplDir$+".Options")
  6721.  f%=0 
  6722. setup_default
  6723.  #f% : 
  6724. error(0) : 
  6725. setup_default : 
  6726. #f%,IcInfo_Active%,DuplNames%,Hatch%,Setup_Support%
  6727. #f%,Grid_SizeLock%,Grid_SizeX%,Grid_SizeY%
  6728. #f%,Grid_PosLock%,Grid_PosX%,Grid_PosY%
  6729. #f%,Save_Unselected%,DeleteOutside%,TrapDclick%,Stats_Decimal%
  6730. #f%,IgnoreDeskFont%,etype%
  6731. export_settype(etype%)
  6732. setup_save
  6733.  (ApplDir$+".Options")
  6734.  f%<>0 
  6735.  #f% : 
  6736. error(0) : 
  6737. #f%,IcInfo_Active%,DuplNames%,Hatch%,Support%
  6738. #f%,Grid_SizeLock%,Grid_SizeX%,Grid_SizeY%
  6739. #f%,Grid_PosLock%,Grid_PosX%,Grid_PosY%
  6740. #f%,Save_Unselected%,DeleteOutside%,TrapDclick%,Stats_Decimal%
  6741. #f%,IgnoreDeskFont%,ExportType%
  6742.  *** procs for statistics window ***
  6743. stat_fillwin
  6744.  wasopen%,ysize%,maxwdef%,totindsize%,i%,wdef%,indsize%,j%,ib%
  6745.  "Hourglass_On"
  6746. sel_get(StatW%)
  6747.  SelBlk%!0=2 
  6748. (  type%=2 : 
  6749.  numbers in hexadecimal
  6750.   type%=1 : 
  6751.  decimal
  6752. WinBlk%!0=StatW%
  6753.  "Wimp_GetWindowInfo",,WinBlk%
  6754. #wasopen%=(WinBlk%!32) 
  6755.  (1<<16)
  6756.  "Wimp_DeleteWindow",,WinBlk%
  6757. WinBlk%!88=15
  6758. -ysize%=204+NrTemplates%*40 : 
  6759.  set extent
  6760. *WinBlk%!8=WinBlk%!16-WinBlk%!24-ysize%
  6761. WinBlk%!48=-ysize%
  6762.  "Wimp_CreateWindow",,WinBlk%+4 
  6763.  StatW%
  6764. WinBlk%!0=StatW%
  6765. linkicontext(25,WinBlk%,5) : 
  6766.  number of templates
  6767. linkicontext(22,WinBlk%,7) : 
  6768.  largest window definition
  6769. linkicontext(23,WinBlk%,9) : 
  6770.  total size of indirected data
  6771. maxwdef%=0
  6772. totindsize%=0
  6773.  i%=0 
  6774.  NrTemplates%-1
  6775. #  WinBlk%!0=TemplHandle%!(4*i%)
  6776.  "Wimp_GetWindowInfo",,WinBlk%
  6777.   wdef%=88+32*WinBlk%!88
  6778. 9  indsize%=
  6779. stat_calcindirsize(WinBlk%!60,WinBlk%+76)
  6780.  WinBlk%!88>0 
  6781.  j%=0 
  6782.  (WinBlk%!88-1)
  6783.       ib%=WinBlk%+92+32*j%
  6784. 6      indsize%+=
  6785. stat_calcindirsize(ib%!16,ib%+20)
  6786. stat_createicon(10,$(TemplNames%+i%*28),i%)
  6787. stat_createicon(11,
  6788. stat_num2str(WinBlk%!88),i%)
  6789. stat_createicon(12,
  6790. stat_num2str(wdef%),i%)
  6791. stat_createicon(13,
  6792. stat_num2str(indsize%),i%)
  6793. stat_createicon(14,
  6794. stat_num2str(wdef%+indsize%),i%)
  6795.   wdef%+=indsize%
  6796.  maxwdef%<wdef% 
  6797.  maxwdef%=wdef%
  6798.   totindsize%+=indsize%
  6799. seticontext(25,
  6800. (NrTemplates%))
  6801. seticontext(22,
  6802. stat_num2str(maxwdef%))
  6803. seticontext(23,
  6804. stat_num2str(totindsize%))
  6805.  wasopen% 
  6806. openwindow(StatW%,0)
  6807. openwindow(StatW%,1)
  6808.  "Hourglass_Off"
  6809.  --- calculate size of indirected data needed for an icon ---
  6810. stat_calcindirsize(flags%,data%)
  6811.  size%
  6812.  (flags% 
  6813.  &800100)=&100 
  6814.   size%=data%!8
  6815.  (flags% 
  6816.  (data%!4<>-1) 
  6817. #    size%=size%+
  6818. ($(data%!4))+1
  6819.   size%=0
  6820. =size%
  6821.  --- create an icon in the stats window ---
  6822. stat_createicon(copyfrom%,s$,line%)
  6823. ScrapBlk%!0=StatW%
  6824. ScrapBlk%!4=copyfrom%
  6825.  "Wimp_GetIconState",,ScrapBlk%
  6826.  create icon that is identical, except for string, colours and Y coord
  6827. ,ScrapBlk%!12=ScrapBlk%!12-4-40*(line%+1)
  6828.  ScrapBlk%!20=ScrapBlk%!12+40
  6829. 9ScrapBlk%!24=(ScrapBlk%!24 
  6830.  &FFFFFF) 
  6831.  Stat_Colours%
  6832. HScrapBlk%!24=ScrapBlk%!24 
  6833.  &100) : 
  6834.  icon must be not-indirected
  6835. $(ScrapBlk%+28)=s$
  6836. ScrapBlk%!4=StatW%
  6837.  "Wimp_CreateIcon",,ScrapBlk%+4
  6838.  --- convert a number to a string (hex or decimal) ---
  6839. stat_num2str(num%)
  6840.  Stats_Decimal% 
  6841.   s$=
  6842. (num%)
  6843.   s$="&"+
  6844. ~(num%)
  6845.  *** procs for handling outline fonts ***
  6846. font_lose(font%)
  6847. FontUsage%(font%)-=1
  6848.  FontUsage%(font%)=0 
  6849.  "Font_LoseFont",font%
  6850. font_loseall
  6851.  i%,j%
  6852.  i%=0 
  6853.  FontUsage%(i%)<>0 
  6854.  "Font_LoseFont",i%
  6855.  --- get font name and size from a font handle ---
  6856. font_getinfo(fhandle%,
  6857.  name$,
  6858.  xsize,
  6859.  ysize)
  6860.  xsize16%,ysize16%
  6861.  "Font_ReadDefn",fhandle%,FontData% 
  6862.  ,,xsize16%,ysize16%
  6863. name$=$(FontData%)
  6864. xsize=xsize16%/16
  6865. ysize=ysize16%/16
  6866.  *** procs for calculating & setting the minimum size of an icon ***
  6867. minimizeiconsel(window%,default%,dim%)
  6868.  i%,xsize%,ysize%,handle%
  6869. sel_get(window%)
  6870.  (NrSelected%=0) 
  6871.  (default%>=0) 
  6872.   SelBlk%!0=default%
  6873.   NrSelected%=1
  6874.  NrSelected%>0 
  6875.  i%=0 
  6876.  NrSelected%-1
  6877. :    
  6878. miniconsize(window%,SelBlk%!(4*i%),xsize%,ysize%)
  6879.     IconBlk%!0=window%
  6880. !    IconBlk%!4=SelBlk%!(4*i%)
  6881. (    
  6882.  "Wimp_GetIconState",,IconBlk%
  6883. 1    
  6884.  dim%<>2 
  6885.  IconBlk%!16=IconBlk%!8+xsize%
  6886. 2    
  6887.  dim%<>1 
  6888.  IconBlk%!20=IconBlk%!12+ysize%
  6889. >    handle%=
  6890. redefineicon(window%,SelBlk%!(4*i%),IconBlk%)
  6891. miniconsize(window%,icon%,
  6892.  minx%,
  6893.  miny%)
  6894.  sparea%,flags%,data%,text%,sprite%,indir%
  6895.  sminx%,sminy%,tminx%,tminy%,p%,val$,sname$,t$
  6896.  xmin%,ymin%,xmax%,ymax%
  6897.  l$,lspace%,lines%,b$
  6898. WinBlk%!0=window%
  6899.  "Wimp_GetWindowInfo",,WinBlk%
  6900. sparea%=WinBlk%!68
  6901. ScrapBlk%!0=window%
  6902. ScrapBlk%!4=icon%
  6903.  "Wimp_GetIconState",,ScrapBlk%
  6904. flags%=ScrapBlk%!24
  6905. data%=ScrapBlk%+28
  6906. text%=(flags% 
  6907.  1)>0
  6908. sprite%=(flags% 
  6909.  2)>0
  6910. indir%=(flags% 
  6911.  &100)>0
  6912.  indir% 
  6913.  text% 
  6914.  (data%!4<>-1) 
  6915.   val$=$(data%!4)
  6916.  sprite% 
  6917.  indir% 
  6918.  text% 
  6919. :4      
  6920.  search validation string for sprite name
  6921. ;-      sname$=
  6922. validationcommand(val$,"S")
  6923.       p%=
  6924. sname$,",")
  6925.       
  6926.  p%>0 
  6927. >"        sname$=
  6928. sname$,2,p%-2)
  6929.       
  6930.         sname$=
  6931. sname$,2)
  6932.       
  6933. B        
  6934.       sname$=$(data%!0)
  6935.       sparea%=data%!4
  6936. E        
  6937.     sname$=$(data%)
  6938. (sname$)>0 
  6939. spritesize(sname$,sparea%,sminx%,sminy%)
  6940.  text% 
  6941.  indir% 
  6942.     t$=$(data%!0)
  6943.     t$=$(data%)
  6944.  flags% 
  6945.  (1<<6) 
  6946. R5    
  6947.  calc size of string printed as outline font
  6948. S&    
  6949.  "Font_SetFont",(flags%>>24)
  6950. T;    
  6951.  "Font_StringBBox",,t$ 
  6952.  ,xmin%,ymin%,xmax%,ymax%
  6953. UG    
  6954.  "Font_ConverttoOS",,xmax%-xmin%,ymax%-ymin% 
  6955.  ,tminx%,tminy%
  6956.     tminx%+=2*PixToOS_X%
  6957.     tminy%+=2*PixToOS_Y%
  6958. Y.    
  6959.  (OSversion%<350) 
  6960.  IgnoreDeskFont% 
  6961. Z'      
  6962.  calc text width in BBC font
  6963.       tminx%=16*
  6964. (t$)+4
  6965. \        
  6966. ]3      
  6967.  calc text width in current desktop font
  6968. ^(      
  6969.  "Wimp_TextOp",1,t$ 
  6970.  tminx%
  6971.       tminx%+=8
  6972. `        
  6973. a-    tminy%=32 : 
  6974.  text height fixed to 32
  6975. c%  l$=
  6976. validationcommand(val$,"L")
  6977. (l$)>0 
  6978. e5    
  6979.  multi-line text - calc Y size, X size fixed
  6980.     lspace%=
  6981. l$,2))
  6982. g     
  6983.  lspace%=0 
  6984.  lspace%=40
  6985. h6    lines%=(tminx%-1) 
  6986.  (ScrapBlk%!16-ScrapBlk%!8)
  6987. i'    tminx%=ScrapBlk%!16-ScrapBlk%!8
  6988. j!    tminy%=lspace%*(lines%+1)
  6989.  flags% 
  6990.  (1<<4) 
  6991.   minx%=sminx%+tminx%
  6992.  minx%=0 
  6993. p>    minx%=ScrapBlk%!16-ScrapBlk%!8 : 
  6994.  don't change X size
  6995. r$    
  6996.  text% 
  6997.  sprite% 
  6998.  minx%+=6
  6999. s5    
  7000.  sminy%>tminy% 
  7001.  miny%=sminy% 
  7002.  miny%=tminy%
  7003.  sminx%>tminx% 
  7004.  minx%=sminx% 
  7005.  minx%=tminx%
  7006.   miny%=sminy%+tminy%
  7007.  flags% 
  7008.  (1<<2) 
  7009.  add space taken by border
  7010. {%  b$=
  7011. validationcommand(val$,"R")
  7012. (b$)=0 
  7013. }7    minx%+=16 : 
  7014.  no border command - "flat" border
  7015.     miny%+=16
  7016. &    
  7017.  found command for 3-D border
  7018. b$,2)) 
  7019.       
  7020.         minx%+=24
  7021.         miny%+=24
  7022.       
  7023.         minx%+=32
  7024.         miny%+=32
  7025.       
  7026.         minx%+=16
  7027.         miny%+=16
  7028.         
  7029.  minx%<16 
  7030.  minx%=16
  7031.  miny%<16 
  7032.  miny%=16
  7033.  --- return size of a sprite in OS units ---
  7034. spritesize(name$,area%,
  7035.  xsize%,
  7036.  ysize%)
  7037.  spmode%,xpixels%,ypixels%
  7038.  area%=1 
  7039.  "XWimp_SpriteOp",40,,name$ 
  7040.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7041.  "XOS_SpriteOp",296,area%,name$ 
  7042.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7043.  (flg% 
  7044. 9    
  7045.  sprite not found in custom area - try wimp area
  7046. J    
  7047.  "XWimp_SpriteOp",40,,name$ 
  7048.  ,,,xpixels%,ypixels%,,spmode%;flg%
  7049.  (flg% 
  7050.   xsize%=0
  7051.   ysize%=0
  7052. *  xsize%=xpixels%<<
  7053. modevar(spmode%,4)
  7054. *  ysize%=ypixels%<<
  7055. modevar(spmode%,5)
  7056.  --- search validation string for a certain command and return it ---
  7057. validationcommand(v$,cmd$)
  7058.  upc$,loc$,p%
  7059. upc$=
  7060. (cmd$) 
  7061.  &DF)
  7062. loc$=
  7063. (cmd$) 
  7064.  &20)
  7065. v$,1)<>upc$) 
  7066. v$,1)<>loc$) 
  7067. (v$)>0)
  7068.   p%=
  7069. v$,";")
  7070.  (p%>1) 
  7071. v$,p%-1,1)="\") 
  7072. v$,";",p%+1)
  7073.  p%=0 
  7074.     v$=""
  7075.     v$=
  7076. v$,p%+1)
  7077. v$,";")
  7078.  p%>0 
  7079. v$,p%-1)
  7080.  *** procs for handling messages in the Messages file ***
  7081. msg_init
  7082.  fname$,flags%,size%,buf%
  7083. fname$=ApplDir$+".Messages"
  7084.  "MessageTrans_FileInfo",,fname$ 
  7085.  flags%,,size%
  7086.  flags% 
  7087.   buf%=0
  7088.   buf%=
  7089. heap_get(size%)
  7090. $MsgDesc%=
  7091. heap_get(17+
  7092. (fname$))
  7093. $(MsgDesc%+16)=fname$
  7094.  "MessageTrans_OpenFile",MsgDesc%,MsgDesc%+16,buf%
  7095. msg_exit
  7096.  "MessageTrans_CloseFile",MsgDesc%
  7097. MsgDesc%=0
  7098. msg_lookup0(token$)
  7099.  result$
  7100.  "MessageTrans_Lookup",MsgDesc%,token$,0 
  7101.  ,,result$
  7102. =result$
  7103. msg_lookup1(token$,param$)
  7104.  result$
  7105.  "MessageTrans_Lookup",MsgDesc%,token$,ScrapBlk%,&100,param$ 
  7106.  ,,result$
  7107. =result$
  7108. msg_lookup2(token$,param1$,param2$)
  7109.  result$
  7110.  "MessageTrans_Lookup",MsgDesc%,token$,ScrapBlk%,&100,param1$,param2$ 
  7111.  ,,result$
  7112. =result$
  7113.  *** procs for loading and using user-sprites ***
  7114.  --- load a sprite file and let all templates use the sprites
  7115. loadusersprites(fname$)
  7116.  UserSprites%<>1 
  7117. heap_release(UserSprites%)
  7118. modulepresent("OLESupport") 
  7119. )    
  7120.  "OLE_DeLinkFile",1,ThisTask%,0
  7121.  fname$="" 
  7122.   UserSprites%=1
  7123. *  UserSprites%=
  7124. loadspritefile(fname$)
  7125.  NrTemplates%>0 
  7126.  no%=0 
  7127.  NrTemplates%-1
  7128. @    
  7129. window_setspritearea(TemplHandle%!(4*no%),UserSprites%)
  7130.  UserSprites%=1 
  7131.   SpriteFname$=""
  7132.   SpriteFname$=fname$
  7133. modulepresent("OLESupport") 
  7134. %    
  7135.  "OLE_SimulateSession",&FF9
  7136. ,    
  7137.  "OLE_LinkFile",fname$,ThisTask%,0
  7138. loadspritefile(fname$)
  7139.  type%,laddr%,fsize%,ftype%,area%
  7140.  "OS_File",17,fname$ 
  7141.  type%,,laddr%,,fsize%
  7142.  (laddr%>>20) 
  7143.  &FFF=&FFF 
  7144.   ftype%=(laddr%>>8) 
  7145.  &FFF
  7146.   ftype%=-1
  7147.  (type%<>1) 
  7148.  (ftype%<>&FF9) 
  7149. complain(
  7150. msg_lookup1("NOSF",fname$))
  7151.   area%=1
  7152.   fsize%+=16
  7153.   area%=
  7154. heap_get(fsize%)
  7155.  area%>0 
  7156.     area%!0=fsize%
  7157.     area%!8=16
  7158. $    
  7159.  "OS_SpriteOp",256+9,area%
  7160. ,    
  7161.  "OS_SpriteOp",256+10,area%,fname$
  7162. H    area%=1 : 
  7163.  couldn't allocate space in heap - reset to Wimp area
  7164. =area%
  7165. window_setspritearea(handle%,area%)
  7166.  icon%,ib%
  7167. WinBlk%!0=handle%
  7168.  "Wimp_GetWindowInfo",,WinBlk%
  7169. $WinBlk%!68=area% : 
  7170.  CBP pointer
  7171. icon_setspritearea(WinBlk%!60,WinBlk%+76,area%)
  7172.  (WinBlk%!88)>0 
  7173.  icon%=0 
  7174.  (WinBlk%!88)-1
  7175.     ib%=WinBlk%+92+icon%*32
  7176. 0    
  7177. icon_setspritearea(ib%!16,ib%+20,area%)
  7178.  icon%
  7179. "&handle%=
  7180. redefinewindow(WinBlk%,0)
  7181. icon_setspritearea(flags%,data%,area%)
  7182.  ((flags% 
  7183.  3)=2) 
  7184.  ((flags% 
  7185.  &100)<>0) 
  7186.   data%!4=area%
  7187.  *** procs for exporting templates ***
  7188. exporttemplates(fname$)
  7189.  handle%,no%
  7190. fname$,".")=0) 
  7191.  (fname$<>"<Wimp$Scrap>") 
  7192. complain(
  7193. msg_lookup0("ISLF"))
  7194.  "Hourglass_On"
  7195.   handle%=
  7196.  fname$
  7197.  #handle% : 
  7198. error(0) : 
  7199.  no%=0 
  7200.  NrTemplates%-1
  7201. 7?    
  7202.  SavingSelection%) 
  7203. iconselected(TemplW%,no%)) 
  7204.       
  7205.  #handle%,
  7206. 48,"-")
  7207. 9<      
  7208.  #handle%,"Template name: "+$(TemplNames%+28*no%)
  7209.       
  7210.  #handle%,
  7211. 48,"-")
  7212. ;'      
  7213. export_template(no%,handle%)
  7214.       
  7215.  #handle%,""
  7216. =        
  7217.  #handle%
  7218.  "OS_File",18,fname$,&FFF
  7219.  "Hourglass_Off"
  7220. export_template(no%,handle%)
  7221.  nricons%,i%,ib%
  7222. G"WinBlk%!0=TemplHandle%!(4*no%)
  7223.  "Wimp_GetWindowInfo",,WinBlk%
  7224.  #handle%,"Visible area   "+
  7225. box2str(WinBlk%+4,8)
  7226.  #handle%,"Work area      "+
  7227. box2str(WinBlk%+44,8)
  7228.  #handle%,"Scroll offset  "+
  7229. rjustify(WinBlk%!20,8)+
  7230. rjustify(WinBlk%!24,8)
  7231.  #handle%,"Minimum size   ";
  7232.  #handle%,
  7233. rjustify((WinBlk%!72) 
  7234.  &FFFF,8);
  7235.  #handle%,
  7236. rjustify((WinBlk%!72)>>16,8)
  7237.  #handle%,"Flags          "+
  7238. export_wflags(WinBlk%!32,no%)
  7239.  #handle%,"Button type    "+$(WinButton%+20*((WinBlk%!64)>>12))
  7240.  #handle%,"Colours:"
  7241.  #handle%,"  Title fg     "+
  7242. (WinBlk%?36)
  7243.  #handle%,"  Title bg     "+
  7244. (WinBlk%?37)
  7245.  #handle%,"  Work fg      "+
  7246. (WinBlk%?38)
  7247.  #handle%,"  Work bg      "+
  7248. (WinBlk%?39)
  7249.  #handle%,"  Scroll outer "+
  7250. (WinBlk%?40)
  7251.  #handle%,"  Scroll inner "+
  7252. (WinBlk%?41)
  7253.  #handle%,"  Input focus  "+
  7254. (WinBlk%?42)
  7255.  #handle%,"Title bar:"
  7256. export_iconcontents(WinBlk%!60,WinBlk%+76,1)
  7257. nricons%=WinBlk%!88
  7258.  #handle%,"No. of icons   "+
  7259. (nricons%)
  7260.  nricons%>0 
  7261.  #handle%,""
  7262.  i%=0 
  7263.  nricons%-1
  7264. `%    
  7265.  #handle%,"Icon #"+
  7266. (i%)+":"
  7267.     ib%=WinBlk%+92+i%*32
  7268. b3    
  7269.  #handle%,"  Position    "+
  7270. box2str(ib%,8)
  7271. c-    
  7272. export_iconcontents(ib%!16,ib%+20,0)
  7273. export_wflags(f%,no%)
  7274.  (f% 
  7275.  (1<<0)) 
  7276. f$,1,1)="t"
  7277.  (f% 
  7278.  (1<<1)) 
  7279. f$,2,1)="M"
  7280.  (f% 
  7281.  (1<<2)) 
  7282. f$,3,1)="v"
  7283.  (f% 
  7284.  (1<<3)) 
  7285. f$,4,1)="h"
  7286.  (f% 
  7287.  (1<<4)) 
  7288. f$,5,1)="A"
  7289.  (PaneFlag%?no%) 
  7290. f$,6,1)="P"
  7291.  (f% 
  7292.  (1<<6)) 
  7293. f$,7,1)="N"
  7294.  (f% 
  7295.  (1<<7)) 
  7296. f$,8,1)="b"
  7297.  (f% 
  7298.  (1<<8)) 
  7299. f$,9,1)="A"
  7300.  (f% 
  7301.  (1<<9)) 
  7302. f$,10,1)="1"
  7303.  (f% 
  7304.  (1<<10)) 
  7305. f$,11,1)="G"
  7306.  (f% 
  7307.  (1<<11)) 
  7308. f$,12,1)="B"
  7309.  (f% 
  7310.  (1<<12)) 
  7311. f$,13,1)="H"
  7312.  (f% 
  7313.  (1<<13)) 
  7314. f$,14,1)="S"
  7315.  (f% 
  7316.  (1<<14)) 
  7317. f$,15,1)="X"
  7318.  (f% 
  7319.  (1<<15)) 
  7320. f$,16,1)="Y"
  7321. f$,17,8)=
  7322. 8,"x")
  7323.  (f% 
  7324.  (1<<24)) 
  7325. f$,25,1)="B"
  7326.  (f% 
  7327.  (1<<25)) 
  7328. f$,26,1)="C"
  7329.  (f% 
  7330.  (1<<26)) 
  7331. f$,27,1)="T"
  7332.  (f% 
  7333.  (1<<27)) 
  7334. f$,28,1)="T"
  7335.  (f% 
  7336.  (1<<28)) 
  7337. f$,29,1)="V"
  7338.  (f% 
  7339.  (1<<29)) 
  7340. f$,30,1)="A"
  7341.  (f% 
  7342.  (1<<30)) 
  7343. f$,31,1)="H"
  7344.  (f% 
  7345.  (1<<31)) 
  7346. f$,32,1)="N"
  7347. export_iconcontents(flags%,data%,tbar%)
  7348.  f$,t%,s%,i%,fn$,fx%,fy%
  7349.  (flags% 
  7350.  (1<<23)) 
  7351.  #handle%,"  ** DELETED **"
  7352.   f$=
  7353.  (flags% 
  7354.  (1<<0)) 
  7355. f$,1,1)="T"
  7356.  (flags% 
  7357.  (1<<1)) 
  7358. f$,2,1)="S"
  7359.  (flags% 
  7360.  (1<<2)) 
  7361. f$,3,1)="B"
  7362.  (flags% 
  7363.  (1<<3)) 
  7364. f$,4,1)="H"
  7365.  (flags% 
  7366.  (1<<4)) 
  7367. f$,5,1)="V"
  7368.  (flags% 
  7369.  (1<<5)) 
  7370. f$,6,1)="F"
  7371.  (flags% 
  7372.  (1<<6)) 
  7373. f$,7,1)="O"
  7374.  (flags% 
  7375.  (1<<7)) 
  7376. f$,8,1)="N"
  7377.  (flags% 
  7378.  (1<<8)) 
  7379. f$,9,1)="I"
  7380.  (flags% 
  7381.  (1<<9)) 
  7382. f$,10,1)="R"
  7383.  (flags% 
  7384.  (1<<10)) 
  7385. f$,11,1)="A"
  7386.  (flags% 
  7387.  (1<<11)) 
  7388. f$,12,1)="H"
  7389. f$,13,9)=
  7390. 9,"x")
  7391.  (flags% 
  7392.  (1<<21)) 
  7393. f$,22,1)="S"
  7394.  (flags% 
  7395.  (1<<22)) 
  7396. f$,23,1)="F"
  7397.  tbar% 
  7398. f$,3,1)="x"
  7399. f$,6,1)="x"
  7400. f$,8,1)="x"
  7401. f$,11,1)="x"
  7402.  #handle%,"  Flags        "+f$
  7403.   t%=(flags% 
  7404.  1)<>0
  7405.   s%=(flags% 
  7406.  1<<1)<>0
  7407.   i%=(flags% 
  7408.  1<<8)<>0
  7409. %    
  7410.  #handle%,"  Text         ";
  7411. ,    
  7412.  #handle%,"  Sprite       ";
  7413. '      
  7414.  #handle%,"'"+$(data%!0)+"'"
  7415.        
  7416.  (data%!4 > 0) 
  7417. ;        
  7418.  #handle%,"  Validation   "+"'"+$(data%!4)+"'"
  7419.       
  7420. 1      
  7421.  #handle%,"  Max. length  "+
  7422. (data%!8)
  7423.         
  7424. #      
  7425.  #handle%,"'"+$data%+"'"
  7426.         
  7427.  tbar%=0 
  7428. H    
  7429.  #handle%,"  Button type  "+$(IcButton%+20*((flags%>>12) 
  7430.  15))
  7431. 9    
  7432.  #handle%,"  ESG          "+
  7433. ((flags%>>16) 
  7434.  (flags% 
  7435.  (1<<6)) 
  7436. 5    
  7437. font_getinfo((flags%>>24) 
  7438.  255,fn$,fx%,fy%)
  7439. .    
  7440.  #handle%,"  Font         "+fn$+", ";
  7441. *    
  7442.  #handle%,
  7443. (fx%)+"x"+
  7444. (fy%)+" pt"
  7445.  tbar%=0 
  7446. ;      
  7447.  #handle%,"  Fg colour    "+
  7448. ((flags%>>24) 
  7449. ;      
  7450.  #handle%,"  Bg colour    "+
  7451. ((flags%>>28) 
  7452.         
  7453. box2str(p%,width%)
  7454. rjustify(p%!0,width%)
  7455. rjustify(p%!4,width%)
  7456. rjustify(p%!8,width%)
  7457. rjustify(p%!12,width%)
  7458. 2s$+="    ("+
  7459. (p%!8-p%!0)+"x"+
  7460. (p%!12-p%!4)+")"
  7461. rjustify(x%,width%)
  7462. (s$)<width% 
  7463. width%-
  7464. (s$)," ")+s$
  7465.  *** procs for exporting icon names ***
  7466. export_settype(type%)
  7467. ExportType%=type%
  7468.  type% 
  7469.  0 : $(ExportFileIcon%)="file_ffb"
  7470.  1,2 : $(ExportFileIcon%)="file_fff"
  7471. seticonstate0(ExportW%,2,0,0)
  7472. selecticon(ExportW%,3+type%,1)
  7473. export_savenames(fname$)
  7474.  handle%,no%,line%
  7475. fname$,".")=0) 
  7476.  (fname$<>"<Wimp$Scrap>") 
  7477. complain(
  7478. msg_lookup0("ISLF"))
  7479.  "Hourglass_On"
  7480.   line%=1
  7481.   handle%=
  7482.  fname$
  7483.  #handle% : 
  7484. error(0) : 
  7485.  ExportType% 
  7486. J      
  7487. export_basicline(handle%,
  7488. (&DD)+" "+
  7489. (&F2)+"iconnumbers",line%)
  7490. )      
  7491.  #handle%,"/* icon numbers */"
  7492. &      
  7493.  #handle%,"# icon numbers" 
  7494.   line%+=1
  7495.  no%=0 
  7496.  NrTemplates%-1
  7497. -    
  7498. export_savenames0(handle%,no%,line%)
  7499.  ExportType% 
  7500. 1      
  7501. export_basicline(handle%,
  7502. (&E1),line%)
  7503.       
  7504.  #handle%,13
  7505.       
  7506.  #handle%,&FF
  7507. %      
  7508.  "OS_File",18,fname$,&FFB
  7509. %      
  7510.  "OS_File",18,fname$,&FFF
  7511.  #handle%
  7512.  "Hourglass_Off"
  7513. export_savenames0(handle%,no%,
  7514.  line%)
  7515.  tname$,nricons%,i%,n$
  7516.  tname$=$(TemplNames%+28*no%)
  7517. "WinBlk%!0=TemplHandle%!(4*no%)
  7518.  "Wimp_GetWindowInfo",,WinBlk%
  7519. nricons%=WinBlk%!88
  7520.  nricons%>0 
  7521.  i%=0 
  7522.  nricons%-1
  7523.     ib%=WinBlk%+92+i%*32
  7524. 1    
  7525.  ((ib%!16 
  7526.  &101)=&101) 
  7527.  (ib%!24<>-1) 
  7528. 2      n$=
  7529. validationcommand($(ib%!24),"N"),2)
  7530.       
  7531. (n$)>0 
  7532.         
  7533.  ExportType% 
  7534.           
  7535. R            
  7536. export_basicline(handle%,
  7537. locase(tname$+"_"+n$)+"%="+
  7538. (i%),line%)
  7539.           
  7540. >            n$="#define "+
  7541. upcase(tname$+"_"+n$)+" "+
  7542.             
  7543.  #handle%,n$
  7544.           
  7545. 3            n$=
  7546. upcase(tname$+"_"+n$)+":"+
  7547.             
  7548.  #handle%,n$ 
  7549.         
  7550.         line%+=1
  7551.       
  7552.         
  7553. export_basicline(handle%,l$,lineno%)
  7554.  #handle%,13
  7555.  #handle%,lineno%>>8
  7556.  #handle%,lineno%
  7557.  #handle%,
  7558. (l$)+4
  7559.  #handle%,l$;
  7560.